ayethuzar commited on
Commit
b23dced
1 Parent(s): b088c0b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ st.title('Sentiment Analysis using Transformers pipeline function')
5
+
6
+ # steamlit form
7
+ form = st.form(key='sentiment-form')
8
+ user_input = form.text_area(label = 'Enter your text', value = "I love steamlit and hugging face!")
9
+ submit = form.form_submit_button('Submit')
10
+
11
+ if submit:
12
+ classifier = pipeline("sentiment-analysis") #using the pipeline() function
13
+ result = classifier(user_input)[0]
14
+ label = result['label']
15
+ score = result['score']
16
+
17
+ if label == 'POSITIVE':
18
+ st.success(f'{label} sentiment (score: {score})')
19
+ else:
20
+ st.error(f'{label} sentiment (score: {score})')