tt-ai / app.py
Kingston Yip
updates
13a9cb2
raw
history blame
859 Bytes
import streamlit as st
from transformers import pipeline
from pysentimiento import create_analyzer
hate_speech_analyzer = create_analyzer(task="hate_speech", lang="es")
pipe = pipeline(task="sentiment-analysis")
st.title("Toxic Tweets Analyzer")
image = "kanye_tweet.jpg"
st.image(image, use_column_width=True)
# create a dropdown to select the model
model = st.selectbox("Select model", ["sentiment-analysis transformer", "finiteautomata/bertweet-base-sentiment-analysis"])
#form
with st.form("my_form"):
submitted = st.form_submit_button("Analyze")
tweet = st.text_area("enter tweet here:", value="i'm nice at ping pong")
if submitted:
out = None
if model == "sentiment-analysis transformer":
out = pipe(tweet)
else:
out = hate_speech_analyzer.predict(tweet)
st.json(out)