Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
# Load the sentiment classifier model | |
distilled_student_sentiment_classifier = pipeline( | |
model="lxyuan/distilbert-base-multilingual-cased-sentiments-student", | |
return_all_scores=True | |
) | |
# Define the Streamlit app | |
def main(): | |
# Add a title to the app | |
st.title("DistilBERT Sentiment Analysis") | |
# Add a text input field for user input | |
user_input = st.text_input("Enter text:") | |
# Perform sentiment analysis when the user submits input | |
if st.button("Analyze"): | |
# Perform sentiment analysis on the input text | |
result = distilled_student_sentiment_classifier(user_input) | |
# Display the sentiment analysis results | |
st.write("Sentiment Analysis Results:") | |
for item in result: | |
st.write(f"Label: {item['label']}, Score: {item['score']}") | |
# Run the Streamlit app | |
if __name__ == "__main__": | |
main() | |