File size: 497 Bytes
466d049
 
 
 
 
 
 
 
 
 
 
3497f5c
466d049
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
from transformers import pipeline

#Load model from HF
clf = pipeline('sentiment-analysis')

#Create Streamlit app
st.title('Sentiment Analysis')
st.write('Enter a text and we will predict its sentiment!')

#Add text box
txt_input = st.text_input('Enter text here:')

#When text is entered, run model
if st.button('Submit'):
    #Predict the sentiment using HF model
    sentiment = clf(txt_input)[0]['label']

    #Display prediction
    st.write(f'Sentiment: {sentiment}')