import streamlit as st from transformers import pipeline from transformers import AutoModelForSequenceClassification, AutoTokenizer # Load the sentiment analysis model from our BERT model classifier = pipeline("text-classification", model = "MarieAngeA13/Sentiment-Analysis-BERT") # Create a Streamlit app st.title('Sentiment Analysis with BERT') st.write('Enter some text and we will predict its sentiment!') # Add a text input box for the user to enter text text_input = st.text_input('Enter text here') # When the user submits text, run the sentiment analysis model on it if st.button('Submit'): # Predict the sentiment of the text using our own BERT model output = classifier(text_input) best_prediction = output[0] sentiment = best_prediction['label'] confidence = best_prediction['score'] # Display the sentiment prediction to the user st.write(f'Sentiment: {sentiment}') st.write(f'Confidence: {round(confidence, 2)}')