AI-project / app.py
corykhal's picture
Update app.py
3265f6b
raw
history blame
No virus
1.16 kB
import streamlit as st
from transformers import pipeline
st.set_page_config(page_title="AI Project", page_icon=":tada:", layout="wide")
with st.container():
st.title("Hello! Welcome to the Sentiment Analysis App :wave:")
st.header("By: Cory Khalilollahi")
with st.container():
st.write("---")
text = st.text_input("Please enter any text to use for the sentiment analysis:",
value="Hello! It is a pleasure to meet you!")
model = st.selectbox(
"Please select one of the following pre-trained models:",
["finiteautomata/bertweet-base-sentiment-analysis",
'bhadresh-savani/distilbert-base-uncased-emotion',
"nlptown/bert-base-multilingual-uncased-sentiment"]
)
analysis = pipeline("sentiment-analysis", model=model)
with st.container():
st.write("---")
if st.button("Analyze!"):
result = analysis(text)
sentiment = result[0]["label"]
score = result[0]["score"]
sentiment = "Sentiment: " + sentiment
score = "Score: " + str(score * 100)[:7] + "%"
st.title(sentiment)
st.title(score)