File size: 977 Bytes
8a4e59f
e4a01a2
7268767
e4a01a2
 
 
 
 
8a4e59f
 
 
e4a01a2
8a4e59f
e4a01a2
 
8a4e59f
8fb2593
 
 
e4a01a2
8a4e59f
e4a01a2
 
 
 
 
 
8a4e59f
e4a01a2
e287e9f
 
8a4e59f
e4a01a2
e287e9f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
import torch
from transformers import AutoModelForSequenceClassification
from transformers import AutoTokenizer, AutoModel
from transformers import pipeline

tokenizer = AutoTokenizer.from_pretrained("Michael54546/ToxicTweet")
model = AutoModelForSequenceClassification.from_pretrained("Michael54546/ToxicTweet")

#st.title("Enter Phrase: ")
uInput = st.text_input("Enter Phrase: ")
data = [uInput]

classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer, return_all_scores=True)
results = classifier(data)

highest=""
highestscore = 0

col1, col2, col3 = st.columns(3)

for x in results:
  for p in x:
    #print(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
    if(p['score']>highestscore and p['label']!='toxic'):
      highestscore=p['score']
      highest=p['label']

col2.header("Highest Label")
#print(highest)
col2.subheader(f"{highest}")

col3.header("Probability")
col3.subheader(f"{ round(highestscore * 100, 1)}%")