taimoor61 commited on
Commit
49e475b
·
1 Parent(s): ccdb81b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
3
+
4
+ # Explicitly specify the sentiment analysis model
5
+ model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
6
+ classifier = pipeline("sentiment-analysis", model=model_name)
7
+
8
+ # Streamlit app
9
+ def main():
10
+ st.title("Sentiment Analysis App")
11
+ user_input = st.text_area("Enter your text:")
12
+
13
+ if st.button("Analyze"):
14
+ if user_input:
15
+ # Make prediction
16
+ prediction = classifier(user_input)
17
+ st.write("Prediction:", prediction[0]["label"], "with confidence:", prediction[0]["score"])
18
+ else:
19
+ st.warning("Please enter some text.")
20
+
21
+ if __name__ == "__main__":
22
+ main()