MarieAngeA13
commited on
Commit
·
5648f24
1
Parent(s):
0c23360
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
# Load the sentiment analysis model from
|
5 |
-
classifier = pipeline(
|
6 |
|
7 |
# Create a Streamlit app
|
8 |
-
st.title('Sentiment Analysis with
|
9 |
st.write('Enter some text and we will predict its sentiment!')
|
10 |
|
11 |
# Add a text input box for the user to enter text
|
@@ -13,8 +14,11 @@ text_input = st.text_input('Enter text here')
|
|
13 |
|
14 |
# When the user submits text, run the sentiment analysis model on it
|
15 |
if st.button('Submit'):
|
16 |
-
# Predict the sentiment of the text using
|
17 |
-
|
|
|
|
|
18 |
|
19 |
# Display the sentiment prediction to the user
|
20 |
-
st.write(f'Sentiment: {
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
4 |
|
5 |
+
# Load the sentiment analysis model from our BERT model
|
6 |
+
classifier = pipeline("text-classification", model = "MarieAngeA13/Sentiment-Analysis-BERT")
|
7 |
|
8 |
# Create a Streamlit app
|
9 |
+
st.title('Sentiment Analysis with BERT')
|
10 |
st.write('Enter some text and we will predict its sentiment!')
|
11 |
|
12 |
# Add a text input box for the user to enter text
|
|
|
14 |
|
15 |
# When the user submits text, run the sentiment analysis model on it
|
16 |
if st.button('Submit'):
|
17 |
+
# Predict the sentiment of the text using our own BERT model
|
18 |
+
output = classifier(text_input)
|
19 |
+
|
20 |
+
best_prediction = output[0]
|
21 |
|
22 |
# Display the sentiment prediction to the user
|
23 |
+
st.write(f'Sentiment: {best_prediction['label']}')
|
24 |
+
st.write(f'Confidence: {best_prediction['score']}')
|