File size: 754 Bytes
f2e85d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

# Carga el modelo fine-tuneado desde tu cuenta
# Reemplaza con TU USUARIO y NOMBRE del modelo en Hugging Face
model_id = "Alejandro-03/fine-tuned-sentiment-v1"

classifier = pipeline("text-classification", model=model_id)

def classify_sentiment(text):
    prediction = classifier(text)[0]
    label = prediction["label"]
    score = round(prediction["score"] * 100, 2)
    return f"{label} ({score}%)"

demo = gr.Interface(
    fn=classify_sentiment,
    inputs="text",
    outputs="text",
    title="Clasificador de Sentimientos",
    description="Escribe una frase en inglés para detectar si el sentimiento es positivo o negativo.",
    theme="default"
)

demo.launch()