Tirath5504's picture
Create app.py
07459be verified
raw
history blame
715 Bytes
import gradio as gr
from transformers import pipeline
import torch
classifier = pipeline(
"text-classification",
model="Tirath5504/IPD-Text-Hinglish",
device=0 if torch.cuda.is_available() else -1
)
def classify_text(text):
result = classifier(text)
return result[0]['label'], result[0]['score']
with gr.Blocks() as demo:
gr.Markdown("# Hate Speech Classification of Hinglish Text")
with gr.Row():
text_input = gr.Textbox(label="Input Text")
label_output = gr.Textbox(label="Predicted Label")
score_output = gr.Number(label="Prediction Score")
text_input.change(fn=classify_text, inputs=text_input, outputs=[label_output, score_output])
demo.launch()