Spaces:
Runtime error
Runtime error
Download app.py from mfernezir/SentimentAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 549 Bytes
-
https://huggingface.co/spaces/mfernezir/SentimentAnalysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/mfernezir/SentimentAnalysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mfernezir/SentimentAnalysis/resolve/main/app.py
549 Bytes
| from transformers import pipeline, Conversation | |
| import gradio as gr | |
| classifier = pipeline(task="text-classification", model="SamLowe/roberta-base-go_emotions", top_k=None) | |
| def top3_text_classes(message, history): | |
| return str(classifier(message)[0][:3]).replace('}, {', '\n').replace('[{', '').replace('}]', '') | |
| demo_sentiment = gr.ChatInterface(top3_text_classes, title="Text Sentiment Chatbot", | |
| description="Enter your text, and the chatbot will classify the sentiment.") | |
| demo_sentiment.launch(share=True) | |