Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| # Load pipeline | |
| def load_pipeline(): | |
| return pipeline("text-classification", model="distilbert/distilbert-base-uncased-finetuned-sst-2-english") | |
| pipe = load_pipeline() | |
| # Streamlit UI | |
| st.title("Sentiment Analysis with DistilBERT") | |
| text = st.text_area("Enter text to analyze sentiment:", height=150) | |
| if st.button("Analyze"): | |
| if text.strip(): | |
| result = pipe(text)[0] | |
| label = result['label'] | |
| score = round(result['score'], 4) | |
| st.success(f"**Sentiment:** {label} ({score})") | |
| else: | |
| st.warning("Please enter some text.") | |