File size: 1,367 Bytes
7717d1f
 
 
 
 
 
 
 
 
 
 
 
 
158e1da
7717d1f
 
 
 
158e1da
7717d1f
 
158e1da
7717d1f
158e1da
7717d1f
158e1da
7717d1f
158e1da
 
 
 
 
7717d1f
 
 
 
b0e73a2
 
7717d1f
 
 
 
158e1da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)