Entregable_3 / app.py
osrojo's picture
Update app.py
158e1da verified
raw
history blame
1.37 kB
from huggingface_hub import from_pretrained_fastai
from fastai.text.all import *
import gradio as gr
# Cargamos el learner
learner = from_pretrained_fastai('osrojo/Emotion')
# Definimos las etiquetas de nuestro modelo
labels = ['0','1','2','3','4','5']
example1 = "would like to take the opportunity to describe one day this week when i was feeling particularly gloomy"
example2 = "i believe that feeling accepted in a non judgemental way can be healing"
example3 = "im feeling somewhat nostalgic about the game just from the fact that its star wars"
example4 = "i am most certainly an acquired taste but lately many of those around me have seemed to feel the taste to be bitter"
example5 = "i feel shy about it all and also a little concerned whether my new title will distance me away from people i care for"
example6 = "i feel like they bring the characters to life completely and i m always kind of surprised what the actors do do together"
# Definimos una función que se encarga de llevar a cabo las predicciones
def predict(text):
pred,pred_idx, probs = learner.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.Textbox(), outputs=gr.Label(),examples=[example1,example2,example3,example4,example5,emample6]).launch(share=False)