Spaces:
Running
Running
Download app.py from Anisha0401/Sentimental_Analysis: direct link, hf CLI and curl.
- Browser
- Download file 622 Bytes
-
https://huggingface.co/spaces/Anisha0401/Sentimental_Analysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/Anisha0401/Sentimental_Analysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Anisha0401/Sentimental_Analysis/resolve/main/app.py
622 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load multilingual sentiment model | |
| sentiment_pipeline = pipeline("sentiment-analysis", model="tabularisai/multilingual-sentiment-analysis") | |
| def analyze_sentiment(text): | |
| result = sentiment_pipeline(text)[0] | |
| return f"{result['label']} ({round(result['score'], 2)})" | |
| iface = gr.Interface( | |
| fn=analyze_sentiment, | |
| inputs=gr.Textbox(label="Enter Text"), | |
| outputs="text", | |
| title="Multilingual Sentiment Analysis 🌐", | |
| description="Analyze text sentiment in multiple languages using Hugging Face." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |