wissamantoun commited on
Commit
d44f5d8
·
1 Parent(s): a49ffd4
Files changed (2) hide show
  1. backend/services.py +7 -7
  2. backend/utils.py +4 -0
backend/services.py CHANGED
@@ -202,16 +202,16 @@ class SentimentAnalyzer:
202
  }
203
 
204
  self.pipelines = {
205
- "sa_trial5_1": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_trial5_1",i), device=-1,return_all_scores =True) for i in range(0,5)],
206
- "sa_no_aoa_in_neutral": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_no_aoa_in_neutral",i), device=-1,return_all_scores =True) for i in range(0,5)],
207
- "sa_cnnbert": [CNNTextClassificationPipeline("{}/train_{}/best_model".format("sa_cnnbert",i), device=-1, return_all_scores =True) for i in range(0,5)],
208
- "sa_sarcasm": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_sarcasm",i), device=-1,return_all_scores =True) for i in range(0,5)],
209
- "sar_trial10": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sar_trial10",i), device=-1,return_all_scores =True) for i in range(0,5)],
210
- "sa_no_AOA": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_no_AOA",i), device=-1,return_all_scores =True) for i in range(0,5)],
211
  }
212
  # fmt: on
213
 
214
- def get_sarcasm_label(self, texts):
215
  prep = self.processors["sar_trial10"]
216
  prep_texts = [prep.preprocess(x) for x in texts]
217
 
 
202
  }
203
 
204
  self.pipelines = {
205
+ "sa_trial5_1": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_trial5_1",i), device=-1,return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sa_trial5_1}"],
206
+ "sa_no_aoa_in_neutral": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_no_aoa_in_neutral",i), device=-1,return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sa_no_aoa_in_neutral}"],
207
+ "sa_cnnbert": [CNNTextClassificationPipeline("{}/train_{}/best_model".format("sa_cnnbert",i), device=-1, return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sa_cnnbert}"],
208
+ "sa_sarcasm": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_sarcasm",i), device=-1,return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sa_sarcasm}"],
209
+ "sar_trial10": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sar_trial10",i), device=-1,return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sar_trial10}"],
210
+ "sa_no_AOA": [pipeline("sentiment-analysis", model="{}/train_{}/best_model".format("sa_no_AOA",i), device=-1,return_all_scores =True) for i in tqdm(range(0,5), desc=f"Loading pipeline for model: sa_no_AOA}"],
211
  }
212
  # fmt: on
213
 
214
+ def get_preds_from_sarcasm(self, texts):
215
  prep = self.processors["sar_trial10"]
216
  prep_texts = [prep.preprocess(x) for x in texts]
217
 
backend/utils.py CHANGED
@@ -1,6 +1,9 @@
1
  import psutil
2
  import os
3
  from tqdm.auto import tqdm
 
 
 
4
 
5
 
6
  def get_current_ram_usage():
@@ -10,6 +13,7 @@ def get_current_ram_usage():
10
 
11
  def download_models(models):
12
  for model in tqdm(models, desc="Downloading models"):
 
13
  for i in range(0, 5):
14
  curr_dir = f"{model}/train_{i}/best_model/"
15
  os.makedirs(curr_dir)
 
1
  import psutil
2
  import os
3
  from tqdm.auto import tqdm
4
+ import logging
5
+
6
+ logger = logging.getLogger(__name__)
7
 
8
 
9
  def get_current_ram_usage():
 
13
 
14
  def download_models(models):
15
  for model in tqdm(models, desc="Downloading models"):
16
+ logger.info(f"Downloading {model}")
17
  for i in range(0, 5):
18
  curr_dir = f"{model}/train_{i}/best_model/"
19
  os.makedirs(curr_dir)