Spaces:
Sleeping
Sleeping
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() |