-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.py
More file actions
24 lines (19 loc) · 768 Bytes
/
deploy.py
File metadata and controls
24 lines (19 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
from transformers import pipeline
st.title('Sentiment Analysis')
st.write('It is using Hugging Face Transformer')
st.write('*Class: Institute of Data, Signapore*')
form = st.form(key='test_form')
user_input = form.text_area('Please provide your text below:')
submit = form.form_submit_button('Submit')
if submit:
classifier = pipeline("sentiment-analysis")
result = classifier(user_input)[0] #it returns list, so take first element
label = result['label']
score = result['score']
if label == 'POSITIVE':
st.success(f'{label} sentiment (score: {score})')
else:
st.error(f'{label} sentiment (score: {score})')
#else:
# st.success(f'{label} sentiment (score: {score})')