Spaces:
Build error
Build error
Download app.py from kya5/CS482-Milestone2: direct link, hf CLI and curl.
- Browser
- Download file 678 Bytes
-
https://huggingface.co/spaces/kya5/CS482-Milestone2/resolve/main/app.py
- Command line
-
hf download hf://spaces/kya5/CS482-Milestone2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kya5/CS482-Milestone2/resolve/main/app.py
678 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| st.title('Sentiment Analysis App') | |
| text = st.text_input(' ') | |
| mname = st.selectbox( | |
| 'Select a pre-trained model', | |
| ['distilbert-base-uncased', 'distilbert-base-cased', 'bert-base-uncased', 'bert-base-cased', | |
| 'cardiffnlp/twitter-roberta-base-sentiment-latest', | |
| 'cardiffnlp/twitter-xlm-roberta-base-sentiment', | |
| 'j-hartmann/emotion-english-distilroberta-base', | |
| 'ProsusAI/finbert' | |
| ] | |
| ) | |
| if st.button('Analyze Sentiment'): | |
| model = pipeline('sentiment-analysis', model=mname) | |
| result = model(text)[0] | |
| st.write(f'Sentiment: {result["label"]}') | |
| st.write(f'Score: {result["score"]}') |