File size: 632 Bytes
1a5f890
632c54c
bf79d0d
 
2268b75
7cf8aab
 
2268b75
 
6767b70
 
2268b75
 
 
 
 
bf79d0d
19c4297
bf79d0d
19c4297
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()