Spaces:
Sleeping
Sleeping
| # app.py | |
| import streamlit as st | |
| from transformers import pipeline | |
| st.title("🤗 Sentiment Detection (Hugging Face Model)") | |
| # Load model once | |
| def load_model(): | |
| return pipeline("sentiment-analysis") | |
| model = load_model() | |
| text = st.text_area("Enter text:") | |
| if st.button("Analyze"): | |
| if text.strip(): | |
| result = model(text)[0] | |
| st.write(f"**Sentiment:** {result['label']} ({round(result['score']*100, 2)}%)") | |
| else: | |
| st.warning("Please enter some text.") | |