File size: 735 Bytes
1ba3302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
from fastai.text.all import *
from fastai.text.all import *
from datasets import load_dataset
from spacy.lemmatizer import Lemmatizer

learn = load_learner('export.pkl')
labels = ['anger','joy','optimism','sadness']

def predict(text):
    aux1,aux2,probs = learn.predict(text)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}
    
# Creamos la interfaz y la lanzamos. 
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=[
            'No but thats so cute. Atsu was probably shy about photos before but cherry helped her out uwu 	',
        ]).launch(share=False)