Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from transformers import pipeline | |
| # Title and description | |
| st.title("Sentiment Analysis") | |
| st.write("This application performs text classification using a pre-trained Hugging Face model.") | |
| # Define the model and pipeline | |
| model_name = "distilbert-base-uncased-finetuned-sst-2-english" | |
| classifier = pipeline("sentiment-analysis", model=model_name) | |
| # Get user input | |
| user_input = st.text_area("Enter text:", placeholder="Type your text here...") | |
| # Analyze and display results | |
| if st.button("Analyze"): | |
| if user_input.strip(): | |
| result = classifier(user_input) | |
| st.write(f"**Result:** {result[0]['label']} ({result[0]['score']:.2f})") | |
| else: | |
| st.warning("Please enter some text.") | |