Spaces:
Sleeping
Sleeping
Commit
·
eedc2ca
1
Parent(s):
06bf7c7
Código inicial app.py
Browse files- app.py +25 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Cargar el modelo DistilBETO
|
5 |
+
sentiment_analysis = pipeline(
|
6 |
+
"sentiment-analysis",
|
7 |
+
model="nlptown/bert-base-multilingual-uncased-sentiment"
|
8 |
+
)
|
9 |
+
|
10 |
+
# Definir la función de análisis de sentimientos
|
11 |
+
def analyze_sentiment(text):
|
12 |
+
results = sentiment_analysis(text)
|
13 |
+
return f"Label: {results[0]['label']}, Score: {results[0]['score']}"
|
14 |
+
|
15 |
+
# Configurar la interfaz de Gradio
|
16 |
+
demo = gr.Interface(
|
17 |
+
fn=analyze_sentiment,
|
18 |
+
inputs="text",
|
19 |
+
outputs="text",
|
20 |
+
title="Análisis de Sentimientos con DistilBETO",
|
21 |
+
description="Ingrese un texto en español para analizar su sentimiento."
|
22 |
+
)
|
23 |
+
|
24 |
+
# Lanzar la aplicación
|
25 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|