Spaces:
Sleeping
Sleeping
| 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 = "I started crying when I saw that little cat standing in the middle of the forest. It reminded me of my poor kitten." | |
| example2 = "I can't wait to see Coldplay's concert next week. It's gonna be great!" | |
| example3 = "The moment I finished reading a Brief History of Time, I knew that my passion would be physics." | |
| example4 = "The fact that I needed to create four Gmail accounts in order to finish this goddammn notebook is quite irritating." | |
| example5 = "i feel agitated with myself that i did not foresee her frustrations earlier leading to the ending of our relationship" | |
| 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,example6]).launch(share=False) |