Spaces:
Running
Running
fix sentiment labeling
Browse files- interfaces/sentiment.py +3 -0
interfaces/sentiment.py
CHANGED
@@ -40,6 +40,9 @@ def predict(text, model_id, tokenizer_id):
|
|
40 |
|
41 |
probs = torch.nn.functional.softmax(logits, dim=1).cpu().numpy().flatten()
|
42 |
output_pred = {model.config.id2label[i]: probs[i] for i in np.argsort(probs)[::-1]}
|
|
|
|
|
|
|
43 |
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>'
|
44 |
return output_pred, output_info
|
45 |
|
|
|
40 |
|
41 |
probs = torch.nn.functional.softmax(logits, dim=1).cpu().numpy().flatten()
|
42 |
output_pred = {model.config.id2label[i]: probs[i] for i in np.argsort(probs)[::-1]}
|
43 |
+
|
44 |
+
output_pred = {4: 2, 5: 1}.get(output_pred, 0)
|
45 |
+
|
46 |
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>'
|
47 |
return output_pred, output_info
|
48 |
|