Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import gradio as gr
|
|
| 5 |
learn = load_learner('nlp_model.pkl')
|
| 6 |
|
| 7 |
labels = learn.dls.vocab
|
|
|
|
| 8 |
|
| 9 |
examples = ["I can't believe you lied to me again! This is unacceptable!",
|
| 10 |
"Got a surprise gift today, feeling overjoyed!"]
|
|
@@ -13,7 +14,7 @@ examples = ["I can't believe you lied to me again! This is unacceptable!",
|
|
| 13 |
|
| 14 |
def classify_text(text):
|
| 15 |
pred,pred_idx,probs = learn.predict(text)
|
| 16 |
-
return {
|
| 17 |
|
| 18 |
interface = gr.Interface(
|
| 19 |
fn=classify_text,
|
|
|
|
| 5 |
learn = load_learner('nlp_model.pkl')
|
| 6 |
|
| 7 |
labels = learn.dls.vocab
|
| 8 |
+
emotion_labels = labels[1]
|
| 9 |
|
| 10 |
examples = ["I can't believe you lied to me again! This is unacceptable!",
|
| 11 |
"Got a surprise gift today, feeling overjoyed!"]
|
|
|
|
| 14 |
|
| 15 |
def classify_text(text):
|
| 16 |
pred,pred_idx,probs = learn.predict(text)
|
| 17 |
+
return {emotion_labels[i]: float(probs[i]) for i in range(len(emotion_labels))}
|
| 18 |
|
| 19 |
interface = gr.Interface(
|
| 20 |
fn=classify_text,
|