kya5's picture
app.py
9782d85
raw
history blame
678 Bytes
import streamlit as st
from transformers import pipeline
st.title('Sentiment Analysis App')
text = st.text_input(' ')
mname = st.selectbox(
'Select a pre-trained model',
['distilbert-base-uncased', 'distilbert-base-cased', 'bert-base-uncased', 'bert-base-cased',
'cardiffnlp/twitter-roberta-base-sentiment-latest',
'cardiffnlp/twitter-xlm-roberta-base-sentiment',
'j-hartmann/emotion-english-distilroberta-base',
'ProsusAI/finbert'
]
)
if st.button('Analyze Sentiment'):
model = pipeline('sentiment-analysis', model=mname)
result = model(text)[0]
st.write(f'Sentiment: {result["label"]}')
st.write(f'Score: {result["score"]}')