|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
classifier = pipeline("sentiment-analysis", model="cardiffnlp/twitter-xlm-roberta-base-sentiment") |
|
|
|
def sentiment_analysis(message, history): |
|
""" |
|
Funci贸n para analizar el sentimiento de un mensaje. |
|
Retorna la etiqueta de sentimiento con su probabilidad. |
|
""" |
|
result = classifier(message) |
|
return f"Sentimiento : {result[0]['label']} (Probabilidad: {result[0]['score']:.2f})" |
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown(""" |
|
# An谩lisis de Sentimientos |
|
Esta aplicaci贸n utiliza un modelo de Machine Learning para analizar el sentimiento de los mensajes ingresados. |
|
Puede detectar si un texto es positivo, negativo o neutral con su respectiva probabilidad. |
|
""") |
|
|
|
chat = gr.ChatInterface(sentiment_analysis, type="messages") |
|
|
|
gr.Markdown(""" |
|
--- |
|
### Con茅ctate conmigo: |
|
[Instagram 馃摳](https://www.instagram.com/srjosueaaron/) |
|
|
|
[TikTok 馃幍](https://www.tiktok.com/@srjosueaaron) |
|
|
|
[YouTube 馃幀](https://www.youtube.com/@srjosueaaron) |
|
|
|
--- |
|
Demostraci贸n de An谩lisis de Sentimientos usando el modelo de [CardiffNLP](https://huggingface.co./cardiffnlp/twitter-xlm-roberta-base-sentiment). |
|
|
|
Desarrollado con 鉂わ笍 por [@srjosueaaron](https://www.instagram.com/srjosueaaron/). |
|
""") |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|