JB007 commited on
Commit
c0b732e
·
1 Parent(s): 45e317b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  st.set_page_config(page_title="My Streamlit Webpage", page_icon=":tada:", layout="wide")
4
  st.subheader("Subheader text comes here :wave:")
@@ -7,6 +8,20 @@ st.write(
7
  "I am passionate about finding ways to leverage ML."
8
  )
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  x = st.slider('Select a value')
11
  st.write(x, 'squared is', x * x)
12
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
  st.set_page_config(page_title="My Streamlit Webpage", page_icon=":tada:", layout="wide")
5
  st.subheader("Subheader text comes here :wave:")
 
8
  "I am passionate about finding ways to leverage ML."
9
  )
10
 
11
+ form = st.form(key='sentiment-form')
12
+ user_input = form.text_area('Enter your text')
13
+ submit = form.form_submit_button('Submit')
14
+
15
+ if submit:
16
+ classifier = pipeline("sentiment-analysis")
17
+ result = classifier(user_input)[0]
18
+ label = result['label']
19
+ score = result['score']
20
+ if label == 'POSITIVE':
21
+ st.success(f'{label} sentiment (score: {score})')
22
+ else:
23
+ st.error(f'{label} sentiment (score: {score})')
24
+
25
  x = st.slider('Select a value')
26
  st.write(x, 'squared is', x * x)
27