milestone-2 / app.py
Matt C
tweak
7cf8aab
raw
history blame
632 Bytes
import streamlit as st
import torch
import plotly.express as px
from transformers import AutoTokenizer, AutoModelForSequenceClassification
deftxt = "I hate you cancerous insects so much"
txt = st.text_area('Text to analyze', deftxt)
# load tokenizer and model weights
tokenizer = AutoTokenizer.from_pretrained("s-nlp/roberta_toxicity_classifier")
model = AutoModelForSequenceClassification.from_pretrained("s-nlp/roberta_toxicity_classifier")
# prepare the input
batch = tokenizer.encode('txt', return_tensors='pt')
# inference
result = model(batch)
print(result)
#fig = px.bar(result, x="", y="", orientation='h')
#fig.show()