Update app.py
Browse files
app.py
CHANGED
|
@@ -7,12 +7,8 @@ learn = from_pretrained_fastai("haripriyaram/Text-emotion-Recognizer-Model")
|
|
| 7 |
# Prediction function
|
| 8 |
def predict_emotion(text):
|
| 9 |
pred_label, _, probs = learn.predict(text)
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
vocab = learn.dls.vocab[0] if isinstance(learn.dls.vocab[1], list) else learn.dls.vocab
|
| 13 |
-
probs_dict = {label: float(prob) for label, prob in zip(vocab, probs)}
|
| 14 |
-
|
| 15 |
-
return prediction, probs_dict
|
| 16 |
|
| 17 |
# Gradio UI
|
| 18 |
iface = gr.Interface(
|
|
|
|
| 7 |
# Prediction function
|
| 8 |
def predict_emotion(text):
|
| 9 |
pred_label, _, probs = learn.predict(text)
|
| 10 |
+
probs_dict = {label: float(prob) for label, prob in zip(learn.dls.vocab, probs)}
|
| 11 |
+
return pred_label, probs_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# Gradio UI
|
| 14 |
iface = gr.Interface(
|