File size: 578 Bytes
27f2be3
 
 
 
 
 
5ba33e0
27f2be3
 
 
 
 
0742a3b
27f2be3
 
3678d5c
5ba33e0
27f2be3
5ba33e0
27f2be3
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

classifier = pipeline("text-classification", model="pysentimiento/robertuito-sentiment-analysis")

def text_to_sentiment(text):
  return {classifier(text)[0]["label"]: classifier(text)[0]["score"]}

demo = gr.Blocks()

with demo:
  with gr.Tabs():
    with gr.TabItem("Análisis de sentimientos de textos en español"):
      with gr.Row():
        texto = gr.Textbox()
        label = gr.Label(num_top_classes=1)
      b1 = gr.Button("Analizar")

    b1.click(text_to_sentiment, inputs=texto, outputs=label)

demo.launch()