Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
| 3 |
+
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 7 |
+
"finiteautomata/beto-sentiment-analysis")
|
| 8 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 9 |
+
"finiteautomata/beto-sentiment-analysis")
|
| 10 |
+
classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
|
| 11 |
+
|
| 12 |
+
from pysentimiento import create_analyzer
|
| 13 |
+
analyzer = create_analyzer(task="sentiment", lang="es")
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def get_sentiment(input_text):
|
| 19 |
+
return analyzer.predict(input_text)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
iface = gr.Interface(fn=get_sentiment,
|
| 23 |
+
inputs="text",
|
| 24 |
+
outputs=["text"],
|
| 25 |
+
description = "Importante colocar solo una oración en español, puede contener emoji😎, para mas info @cesarriat",
|
| 26 |
+
title="Analisis de Sentimiento en Español ")
|
| 27 |
+
iface.launch(inline=False)
|
| 28 |
+
|