Spaces:
Runtime error
Runtime error
Download src/streamlit_app.py from WilleWimseteWilliam/testSpace: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/spaces/WilleWimseteWilliam/testSpace/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/WilleWimseteWilliam/testSpace/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/WilleWimseteWilliam/testSpace/resolve/main/src/streamlit_app.py
636 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| st.title("Sentiment Analysis") | |
| def load_pipe(): | |
| return pipeline("sentiment-analysis") | |
| sentiment_analysis_classifier = load_pipe() | |
| user_input = st.text_area("Enter text to analyze:") | |
| if st.button("Analyze"): | |
| if user_input: | |
| result = sentiment_analysis_classifier(user_input)[0] | |
| label = result['label'] | |
| score = result['score'] | |
| st.write(f"**Sentiment:** {label}") | |
| st.progress(score) | |
| st.write(f"Confidence: {100*score:.2f}%") | |
| else: | |
| st.warning("Please enter some text.") |