Rob Caamano
Update app.py
fd77815 unverified
raw
history blame
864 Bytes
from transformers import AutoTokenizer
import streamlit as st
from transformers import pipeline
from transformers import (
TFAutoModelForSequenceClassification as AutoModelForSequenceClassification,
)
st.title("Detecting Toxic Tweets")
demo = """I'm so proud of myself for accomplishing my goals today. #motivation #success"""
text = st.text_area("Input text", demo, height=250)
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
clf = pipeline(
"toxicity-analysis", model=model, tokenizer=tokenizer, return_all_scores=True
)
input = tokenizer(text, return_tensors="tf")
if st.button("Submit", type="primary"):
results = clf(text)[0]
classes = dict(d.values() for d in results)
st.bar_chart(classes)