Spaces:
Sleeping
Sleeping
| # Import libraries | |
| from transformers import pipeline | |
| import gradio as gr | |
| # Initialize Sentiment Classification Model | |
| model_name = 'pysentimiento/robertuito-sentiment-analysis' | |
| classifier = pipeline("text-classification", model=model_name) | |
| def classify_text(text): | |
| result = classifier(text)[0]['label'] | |
| if result == "POS": | |
| return "Positivo" | |
| elif result == "NEG": | |
| return "Negativo" | |
| else: | |
| return "Neutro" | |
| # Create Gradio Interface | |
| input_text = gr.inputs.Textbox(label="Texto a clasificar") | |
| output_text = gr.outputs.Textbox(label="Sentimiento") | |
| gr.Interface(fn=classify_text, inputs=input_text, outputs=output_text, examples=[ | |
| ['Estoy feliz 🤗 de mostrarles un toolkit para Análisis de Sentimientos y otras tareas de SocialNLP'], | |
| ['Espero que no lo odien.'], | |
| ['Lo odiamos.'] | |
| ]).launch() | |