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)}%")