Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,19 +6,8 @@ import torch
|
|
6 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
7 |
|
8 |
def get_hatespeech_score(text):
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
# Tokenize input text
|
13 |
-
inputs = tokenizer(text, return_tensors='pt')
|
14 |
-
|
15 |
-
# Perform inference
|
16 |
-
outputs = model(**inputs)
|
17 |
-
|
18 |
-
# Get predicted label
|
19 |
-
predicted_label_idx = torch.argmax(outputs.logits).item()
|
20 |
-
predicted_label = model.config.id2label[predicted_label_idx]
|
21 |
-
return predicted_label
|
22 |
|
23 |
def text_analysis(text):
|
24 |
label_1 = get_hatespeech_score(text)
|
|
|
6 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
7 |
|
8 |
def get_hatespeech_score(text):
|
9 |
+
io = gr.Interface.load("unhcr/hatespeech-detection")
|
10 |
+
return io(text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def text_analysis(text):
|
13 |
label_1 = get_hatespeech_score(text)
|