Spaces:
Sleeping
Sleeping
Arnaldo Mont'Alvao
commited on
Commit
·
466d049
1
Parent(s):
ee7d3a2
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
#Load model from HF
|
| 5 |
+
clf = pipeline('sentiment-analysis')
|
| 6 |
+
|
| 7 |
+
#Create Streamlit app
|
| 8 |
+
st.title('Sentiment Analysis')
|
| 9 |
+
st.write('Enter a text and we will predict its sentiment!')
|
| 10 |
+
|
| 11 |
+
#Add text box
|
| 12 |
+
txt_input = st.text_input('Enter text here')
|
| 13 |
+
|
| 14 |
+
#When text is entered, run model
|
| 15 |
+
if st.button('Submit'):
|
| 16 |
+
#Predict the sentiment using HF model
|
| 17 |
+
sentiment = clf(txt_input)[0]['label']
|
| 18 |
+
|
| 19 |
+
#Display prediction
|
| 20 |
+
st.write(f'Sentiment: {sentiment}')
|