Di12 commited on
Commit
71672d1
·
verified ·
1 Parent(s): 32b1dc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -205,7 +205,7 @@ def predict_sentiment(model, sentence, vocab, label_mapping=None):
205
  with torch.no_grad():
206
  logits = model(tensor, length).squeeze(0)
207
  probs = F.softmax(logits, dim=-1).cpu().tolist()
208
- probs = [round(p, 3) for p in probs]
209
  idx = int(torch.tensor(probs).argmax())
210
  return (label_mapping[idx], probs) if label_mapping else (idx, probs)
211
 
@@ -266,9 +266,9 @@ def process_input(text_input, file):
266
  df2 = pd.DataFrame(results)
267
 
268
  styler = df2.style.format({
269
- "Khả năng tiêu cực": "{:.2%}",
270
- "Khả năng bình thường": "{:.2%}",
271
- "Khả năng tích cực": "{:.2%}",
272
  })
273
 
274
  return styler
 
205
  with torch.no_grad():
206
  logits = model(tensor, length).squeeze(0)
207
  probs = F.softmax(logits, dim=-1).cpu().tolist()
208
+ probs = [round(p, 2) for p in probs]
209
  idx = int(torch.tensor(probs).argmax())
210
  return (label_mapping[idx], probs) if label_mapping else (idx, probs)
211
 
 
266
  df2 = pd.DataFrame(results)
267
 
268
  styler = df2.style.format({
269
+ "Khả năng tiêu cực": "{:.0%}",
270
+ "Khả năng bình thường": "{:.0%}",
271
+ "Khả năng tích cực": "{:.0%}",
272
  })
273
 
274
  return styler