Spaces:
Runtime error
Runtime error
Fixing result error
Browse files- app.py +2 -1
- requirements.txt +3 -1
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
|
|
4 |
|
5 |
model_name = "ciro-c/emobot"
|
6 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
@@ -20,7 +21,7 @@ def predict(text):
|
|
20 |
|
21 |
outputs = model(**inputs)
|
22 |
predictions = outputs.logits
|
23 |
-
result = predictions.item()
|
24 |
result = max(result, 0)
|
25 |
result = min(result, 5)
|
26 |
return mapping[round(result)]
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
3 |
import torch
|
4 |
+
import numpy as np
|
5 |
|
6 |
model_name = "ciro-c/emobot"
|
7 |
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
|
|
21 |
|
22 |
outputs = model(**inputs)
|
23 |
predictions = outputs.logits
|
24 |
+
result = np.exp(predictions.item())
|
25 |
result = max(result, 0)
|
26 |
result = min(result, 5)
|
27 |
return mapping[round(result)]
|
requirements.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
1 |
gradio
|
2 |
transformers
|
3 |
-
torch
|
|
|
|
1 |
+
pip
|
2 |
gradio
|
3 |
transformers
|
4 |
+
torch
|
5 |
+
numpy
|