Tirath5504 commited on
Commit
07459be
1 Parent(s): 2acf156

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import torch
4
+
5
+ classifier = pipeline(
6
+ "text-classification",
7
+ model="Tirath5504/IPD-Text-Hinglish",
8
+ device=0 if torch.cuda.is_available() else -1
9
+ )
10
+
11
+ def classify_text(text):
12
+ result = classifier(text)
13
+ return result[0]['label'], result[0]['score']
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown("# Hate Speech Classification of Hinglish Text")
17
+ with gr.Row():
18
+ text_input = gr.Textbox(label="Input Text")
19
+ label_output = gr.Textbox(label="Predicted Label")
20
+ score_output = gr.Number(label="Prediction Score")
21
+
22
+ text_input.change(fn=classify_text, inputs=text_input, outputs=[label_output, score_output])
23
+
24
+ demo.launch()