File size: 904 Bytes
49e475b
 
a4b5dc0
 
 
 
 
 
 
 
b85eb1f
49e475b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()