File size: 1,040 Bytes
c75eb68
 
 
 
 
 
 
 
ad095a0
c75eb68
 
 
 
 
 
 
ad095a0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from fastai.text.all import *
import gradio as gr


# Cargamos el learner
learn = load_learner('export.pkl')

# Definimos las etiquetas de nuestro modelo
labels = ["anger", "joy", "optimism", "sadness"]

# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(txt):
    pred,pred_idx,probs = learn.predict(txt)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}
    
# Creamos la interfaz y la lanzamos. 
gr.Interface(fn=predict, inputs="text", outputs=gr.outputs.Label(),examples=["@user but your pussy was weak from what I heard so stfu up to me bitch . You got to threaten him that your pregnant .\n", "Worry is a down payment on a problem you may never have.  Joyce Meyer. #motivation #leadership #worry\n", "My roommate: it's okay that we can't spell because we have autocorrect. #terrible #firstworldprobs\n", "it's pretty depressing when u hit pan on ur favourite highlighter\n", "Tiller and breezy should do a collab album. Rapping and singing prolly be fire\n"]).launch(share=False)