joulammous commited on
Commit
8bd9826
2 Parent(s): de9105b e0d35f1

Merge pull request #8 from joulammous/milestone-2

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -7,25 +7,31 @@ from transformers import pipeline
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}")
 
7
 
8
  # Milestone 2
9
 
10
+ # title
 
 
 
11
  st.title("Sentiment Analysis App")
12
  st.write("Enter some text and I'll predict its sentiment!")
13
 
14
  # add a text input box
15
  text_input = st.text_input("Enter your text here:", value = "The weather is nice today.")
16
 
17
+ # use a select box for pretrained models
18
+ option = st.selectbox(
19
+ "Select a pretrained model for sentiment analysis",
20
+ ("siebert/sentiment-roberta-large-english", "yiyanghkust/finbert-tone", "finiteautomata/bertweet-base-sentiment-analysis"))
21
+
22
+ # display selection
23
+ st.write("You selected:", option)
24
+
25
+ # run pipeline
26
+ sentiment_pipeline = pipeline("sentiment-analysis", model = option)
27
+
28
  # run the model when the user clicks submit
29
  if st.button("Submit"):
 
 
30
  sentiment = sentiment_pipeline(text_input)
31
 
32
  # split into sentiment and score
33
  sen = sentiment[0]['label']
34
  score = round(sentiment[0]['score'], 4)
35
 
36
+ # get results
37
  st.write(f"Sentiment: {sen} , Confidence Score: {score}")