Spaces:
Running
Running
kovacsvi
commited on
Commit
·
d73b37f
1
Parent(s):
27a48cb
out of scope .. again
Browse files- interfaces/emotion9.py +6 -3
interfaces/emotion9.py
CHANGED
@@ -58,9 +58,12 @@ def predict(text, model_id, tokenizer_id):
|
|
58 |
probs = torch.nn.functional.softmax(logits, dim=1).cpu().numpy().flatten()
|
59 |
|
60 |
if "v2" in model_id:
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
64 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|
65 |
return output_pred, output_info
|
66 |
|
|
|
58 |
probs = torch.nn.functional.softmax(logits, dim=1).cpu().numpy().flatten()
|
59 |
|
60 |
if "v2" in model_id:
|
61 |
+
label_names = EMOTION9_V2_LABEL_NAMES
|
62 |
+
else:
|
63 |
+
label_names = EMOTION9_LABEL_NAMES
|
64 |
+
|
65 |
+
NUMS_DICT = {i: key for i, key in enumerate(sorted(label_names.keys()))}
|
66 |
+
output_pred = {f"[{NUMS_DICT[i]}] {label_names[NUMS_DICT[i]]}": probs[i] for i in np.argsort(probs)[::-1]}
|
67 |
output_info = f'<p style="text-align: center; display: block">Prediction was made using the <a href="https://huggingface.co/{model_id}">{model_id}</a> model.</p>'
|
68 |
return output_pred, output_info
|
69 |
|