Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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,
|
| 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": "{:.
|
| 270 |
-
"Khả năng bình thường": "{:.
|
| 271 |
-
"Khả năng tích cực": "{:.
|
| 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
|