Sergiu2404 commited on
Commit
ed6c508
·
1 Parent(s): eac0e79

refactor app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -16,12 +16,17 @@ model.load_state_dict(torch.load(os.path.join(MODEL_DIR, "regressor_model.pt"),
16
  model.eval()
17
 
18
  def predict_sentiment(text):
 
19
  processed = preprocess_texts([text])[0]
 
 
20
  inputs = tokenizer(processed, return_tensors="pt", truncation=True, padding='max_length', max_length=128)
21
  inputs = {k: v.to(DEVICE) for k, v in inputs.items() if k != "token_type_ids"}
22
  with torch.no_grad():
23
  score = model(**inputs)["score"].item()
24
 
 
 
25
  if score > 0.3:
26
  interpretation = "positive"
27
  elif score < -0.3:
 
16
  model.eval()
17
 
18
  def predict_sentiment(text):
19
+ print(f"[DEBUG] Input text: {text}")
20
  processed = preprocess_texts([text])[0]
21
+ print(f"[DEBUG] Processed text: {processed}")
22
+
23
  inputs = tokenizer(processed, return_tensors="pt", truncation=True, padding='max_length', max_length=128)
24
  inputs = {k: v.to(DEVICE) for k, v in inputs.items() if k != "token_type_ids"}
25
  with torch.no_grad():
26
  score = model(**inputs)["score"].item()
27
 
28
+ print(f"[DEBUG] Score: {score}")
29
+
30
  if score > 0.3:
31
  interpretation = "positive"
32
  elif score < -0.3: