hate_classifier / app.py
nebiyu29's picture
makeing the first interface
a8c9879 verified
raw
history blame
No virus
859 Bytes
from transformers import AuotoTokenizer,AutoModelForSequenceClassification
import gradio as gr
model_name="nebiyu29/hate_classifier"
tokenizer=AuotoTokenizer.from_pretrained(model_name)
model=AutoModelfForSequenceClassification.from_pretrained(model_name)
#this where the model is active
def model_classifier(text):
if text is "":
return f"the input text is {text}"
else:
encoded_input=tokenizer(text) #this is where the encoding happens
scores=model(encoded) #this is is the score for rach values
return scores
#lets write something that accepts input as text and returns the most likely out come out of 3
demo=gr.Interface(
fn=model_classifier,
inputs=gr.Textbox(lines=5,label="Enter you text"),
outputs=gr.Textbox(lines=5,label="Label scores"),
title="Hate Classifier Demo App"
)
demo.launch()