import streamlit as st from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer import subprocess # Install TensorFlow subprocess.run(["pip", "install", "tensorflow==2.0"]) # Install PyTorch subprocess.run(["pip", "install", "torch"]) # Explicitly specify the sentiment analysis model model_name = "nlptown/bert-base-multilingual-uncased-sentiment" classifier = pipeline("sentiment-analysis", model=model_name) # Streamlit app def main(): st.title("Sentiment Analysis App") user_input = st.text_area("Enter your text:") if st.button("Analyze"): if user_input: # Make prediction prediction = classifier(user_input) st.write("Prediction:", prediction[0]["label"], "with confidence:", prediction[0]["score"]) else: st.warning("Please enter some text.") if __name__ == "__main__": main()