Spaces:
Runtime error
Runtime error
Merge pull request #6 from joulammous/milestone-2
Browse files
app.py
CHANGED
@@ -7,18 +7,25 @@ from transformers import pipeline
|
|
7 |
|
8 |
# Milestone 2
|
9 |
|
|
|
10 |
sentiment_pipeline = pipeline("sentiment-analysis", model = "siebert/sentiment-roberta-large-english")
|
11 |
|
12 |
-
|
13 |
-
st.
|
|
|
14 |
|
15 |
-
#
|
16 |
-
text_input = st.text_input(
|
17 |
|
18 |
-
#
|
19 |
-
if st.button(
|
20 |
-
# Predict the sentiment of the text using the Hugging Face model
|
21 |
-
sentiment = sentiment_pipeline(text_input)[0]['label']
|
22 |
|
23 |
-
#
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Milestone 2
|
9 |
|
10 |
+
# select a pretrained model
|
11 |
sentiment_pipeline = pipeline("sentiment-analysis", model = "siebert/sentiment-roberta-large-english")
|
12 |
|
13 |
+
# intro
|
14 |
+
st.title("Sentiment Analysis App")
|
15 |
+
st.write("Enter some text and I'll predict its sentiment!")
|
16 |
|
17 |
+
# add a text input box
|
18 |
+
text_input = st.text_input("Enter your text here:", value = "The weather is nice today.")
|
19 |
|
20 |
+
# run the model when the user clicks submit
|
21 |
+
if st.button("Submit"):
|
|
|
|
|
22 |
|
23 |
+
# get result
|
24 |
+
sentiment = sentiment_pipeline(text_input)
|
25 |
+
|
26 |
+
# split into sentiment and score
|
27 |
+
sen = sentiment[0]['label']
|
28 |
+
score = round(sentiment[0]['score'], 4)
|
29 |
+
|
30 |
+
# display the prediction
|
31 |
+
st.write(f"Sentiment: {sen} , Confidence Score: {score}")
|