Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,12 +28,32 @@ binary_mapping = {
|
|
| 28 |
'LABEL_1': 'hateful',
|
| 29 |
}
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
category_mapping = {
|
| 32 |
'LABEL_0': 'non-hateful',
|
| 33 |
-
'LABEL_1': 'symbolization',
|
| 34 |
-
'LABEL_2': '
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
|
|
@@ -52,13 +72,17 @@ def perform_binary_classification(input_text, selected_model):
|
|
| 52 |
return binary_mapping.get(model(input_text)[0]['label'], 'error')
|
| 53 |
|
| 54 |
def perform_categorization(input_text):
|
| 55 |
-
model = pipeline(model=f'gokceuludogan/berturk_tr_hateprint_cat_w0.1_b128')
|
| 56 |
return category_mapping.get(model(input_text)[0]['label'], 'error')
|
| 57 |
|
| 58 |
-
def perform_target_detection(input_text):
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
def perform_multi_detection(input_text):
|
| 63 |
model = pipeline(model='gokceuludogan/turna_generation_tr_hateprint_multi')
|
| 64 |
return model(input_text)[0]['generated_text']
|
|
@@ -77,7 +101,7 @@ with gr.Blocks(theme="abidlabs/Lime") as hate_speech_demo:
|
|
| 77 |
model_choice_binary = gr.Radio(
|
| 78 |
choices=[
|
| 79 |
"turna_tr_hateprint_w0.1_new_",
|
| 80 |
-
"berturk_tr_hateprint_w0.1",
|
| 81 |
],
|
| 82 |
label="Select Model",
|
| 83 |
value="turna_tr_hateprint"
|
|
|
|
| 28 |
'LABEL_1': 'hateful',
|
| 29 |
}
|
| 30 |
|
| 31 |
+
# category_mapping = {
|
| 32 |
+
# 'LABEL_0': 'non-hateful',
|
| 33 |
+
# 'LABEL_1': 'symbolization',
|
| 34 |
+
# 'LABEL_2': 'exaggeration/generalization/attribution/distortion',
|
| 35 |
+
# 'LABEL_3': 'swearing/insult/defamation/dehumanization',
|
| 36 |
+
# 'LABEL_4': 'threat of enmity/war/attack/murder/harm',
|
| 37 |
+
# }
|
| 38 |
+
|
| 39 |
category_mapping = {
|
| 40 |
'LABEL_0': 'non-hateful',
|
| 41 |
+
'LABEL_1': 'symbolization/exaggeration/generalization/attribution/distortion',
|
| 42 |
+
'LABEL_2': 'swearing/insult/defamation/dehumanization/threat of enmity/war/attack/murder/harm',
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
target_mapping = {
|
| 46 |
+
'LABEL_0': 'No-group',
|
| 47 |
+
'LABEL_1': 'Refugees',
|
| 48 |
+
'LABEL_2': 'Israel-Jews',
|
| 49 |
+
'LABEL_3': 'Greeks',
|
| 50 |
+
'LABEL_4': 'Armenian',
|
| 51 |
+
'LABEL_5': 'Alevi',
|
| 52 |
+
'LABEL_6': 'Kurdish',
|
| 53 |
+
'LABEL_7': 'Arabian',
|
| 54 |
+
'LABEL_8': 'LGBTI+',
|
| 55 |
+
'LABEL_9': 'Women',
|
| 56 |
+
'LABEL_10': 'Other groups'
|
| 57 |
}
|
| 58 |
|
| 59 |
|
|
|
|
| 72 |
return binary_mapping.get(model(input_text)[0]['label'], 'error')
|
| 73 |
|
| 74 |
def perform_categorization(input_text):
|
| 75 |
+
model = pipeline(model='gokceuludogan/berturk_tr_hateprint_cat_class_w0.1_b128') # f'gokceuludogan/berturk_tr_hateprint_cat_w0.1_b128')
|
| 76 |
return category_mapping.get(model(input_text)[0]['label'], 'error')
|
| 77 |
|
| 78 |
+
# def perform_target_detection(input_text):
|
| 79 |
+
# model = pipeline(model='gokceuludogan/turna_generation_tr_hateprint_target')
|
| 80 |
+
# return model(input_text)[0]['generated_text']
|
| 81 |
|
| 82 |
+
def perform_target_detection(input_text):
|
| 83 |
+
model = pipeline(model='gokceuludogan/berturk_tr_hateprint_target_class_w0.1') # f'gokceuludogan/berturk_tr_hateprint_cat_w0.1_b128')
|
| 84 |
+
return target_mapping.get(model(input_text)[0]['label'], 'error')
|
| 85 |
+
|
| 86 |
def perform_multi_detection(input_text):
|
| 87 |
model = pipeline(model='gokceuludogan/turna_generation_tr_hateprint_multi')
|
| 88 |
return model(input_text)[0]['generated_text']
|
|
|
|
| 101 |
model_choice_binary = gr.Radio(
|
| 102 |
choices=[
|
| 103 |
"turna_tr_hateprint_w0.1_new_",
|
| 104 |
+
"berturk_tr_hateprint_w0.1_b128_v2", # "berturk_tr_hateprint_w0.1",
|
| 105 |
],
|
| 106 |
label="Select Model",
|
| 107 |
value="turna_tr_hateprint"
|