Spaces:
Runtime error
Runtime error
makeing the first interface
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AuotoTokenizer,AutoModelForSequenceClassification
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
model_name="nebiyu29/hate_classifier"
|
5 |
+
tokenizer=AuotoTokenizer.from_pretrained(model_name)
|
6 |
+
model=AutoModelfForSequenceClassification.from_pretrained(model_name)
|
7 |
+
|
8 |
+
#this where the model is active
|
9 |
+
def model_classifier(text):
|
10 |
+
if text is "":
|
11 |
+
return f"the input text is {text}"
|
12 |
+
else:
|
13 |
+
encoded_input=tokenizer(text) #this is where the encoding happens
|
14 |
+
scores=model(encoded) #this is is the score for rach values
|
15 |
+
return scores
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
#lets write something that accepts input as text and returns the most likely out come out of 3
|
21 |
+
demo=gr.Interface(
|
22 |
+
fn=model_classifier,
|
23 |
+
inputs=gr.Textbox(lines=5,label="Enter you text"),
|
24 |
+
outputs=gr.Textbox(lines=5,label="Label scores"),
|
25 |
+
title="Hate Classifier Demo App"
|
26 |
+
)
|
27 |
+
demo.launch()
|