Spaces:
Sleeping
Sleeping
Download app.py from Sahar7888/Sentiment_Analysis: direct link, hf CLI and curl.
- Browser
- Download file 874 Bytes
-
https://huggingface.co/spaces/Sahar7888/Sentiment_Analysis/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sahar7888/Sentiment_Analysis/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sahar7888/Sentiment_Analysis/resolve/main/app.py
874 Bytes
| ##Package | |
| import torch | |
| from transformers import pipeline | |
| import gradio as gr | |
| pipe_new = pipeline(task="text-classification", | |
| model="nlptown/bert-base-multilingual-uncased-sentiment") | |
| def sentiment_score(text): | |
| return pipe_new(text)[0]['label'] | |
| # Create title, description and article strings | |
| title = "Sentiment Analysis" | |
| description = "This model predicts the sentiment of the review as a number of stars (between 1 and 5) using nlptown/bert-base-multilingual-uncased-sentiment model" | |
| # article = "This model predicts the sentiment of the review as a number of stars (between 1 and 5) using nlptown/bert-base-multilingual-uncased-sentiment model" | |
| demo = gr.Interface(fn=sentiment_score, | |
| inputs="text", | |
| outputs="text", | |
| title=title, | |
| description=description) | |
| # Launch the app! | |
| demo.launch() | |