Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.text.all import *
|
3 |
+
from fastai.text.all import *
|
4 |
+
from datasets import load_dataset
|
5 |
+
from spacy.lemmatizer import Lemmatizer
|
6 |
+
|
7 |
+
learn = load_learner('export.pkl')
|
8 |
+
labels = ['anger','joy','optimism','sadness']
|
9 |
+
|
10 |
+
def predict(text):
|
11 |
+
aux1,aux2,probs = learn.predict(text)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
# Creamos la interfaz y la lanzamos.
|
15 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Textbox(lines=3,placeholder="Type a phrase that has some emotion",label="Input Text",), outputs=gr.outputs.Label(num_top_classes=4),examples=[
|
16 |
+
'No but thats so cute. Atsu was probably shy about photos before but cherry helped her out uwu ',
|
17 |
+
]).launch(share=False)
|