Spaces:
Sleeping
Sleeping
File size: 843 Bytes
3061ca9 226cf35 3061ca9 226cf35 3061ca9 b5bbbbd 226cf35 3061ca9 af6166c 3061ca9 b5bbbbd |
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 |
# 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()
|