hafsa101010 commited on
Commit
9fbe8d2
·
verified ·
1 Parent(s): 07f578c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Cargar el modelo
5
+ classifier = pipeline("text-classification", model="hafsa101010/clasificador-tweets-sentiment")
6
+
7
+ # Definir la interfaz
8
+ def classify_sentiment(text):
9
+ result = classifier(text)[0]
10
+ label_map = {
11
+ "LABEL_0": "negative",
12
+ "LABEL_1": "neutral",
13
+ "LABEL_2": "positive"
14
+ }
15
+ return f"{label_map.get(result['label'], result['label'])} ({round(result['score']*100, 2)}%)"
16
+
17
+ demo = gr.Interface(fn=classify_sentiment, inputs="text", outputs="text", title="Clasificador de Sentimientos en Tweets")
18
+
19
+ demo.launch()