Spaces:
Sleeping
Sleeping
| from huggingface_hub import from_pretrained_fastai | |
| from fastai.text.all import * | |
| import gradio as gr | |
| # Cargamos el learner | |
| repo_id = "PablitoGil14/ModelEmotions" | |
| learner = from_pretrained_fastai(repo_id) | |
| # Definimos las etiquetas de nuestro modelo | |
| labels = ['0','1','2','3'] | |
| example1 = "I cant believe this happened. It was terrible" | |
| example2 = "Thats fantastic news!" | |
| example3 = "I am very irate by your complete disregard for honesty and decency. Your actions are unacceptable. Go screw yourself." | |
| # 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]).launch(share=False) | |