Spaces:
Runtime error
Runtime error
Commit
·
5d1afde
1
Parent(s):
7c236b9
offensive
Browse files
app.py
CHANGED
@@ -37,6 +37,11 @@ This box presents a detailed breakdown of the evaluation for each model.
|
|
37 |
(Esta caixa apresenta um detalhamento da avaliação para cada modelo.)
|
38 |
""" }
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
score_descriptions = {
|
41 |
0: "This text is not offensive.",
|
42 |
1: "This text is offensive.",
|
@@ -96,14 +101,16 @@ def predict(s1, chosen_model):
|
|
96 |
logits = softmax(logits).tolist()
|
97 |
break
|
98 |
def get_description(idx):
|
99 |
-
description =
|
100 |
description_pt = score_descriptions_pt[idx]
|
101 |
final_description = description + "\n \n" + description_pt
|
102 |
return final_description
|
103 |
|
104 |
-
|
|
|
|
|
105 |
|
106 |
-
return scores
|
107 |
|
108 |
|
109 |
inputs = [
|
@@ -112,6 +119,7 @@ inputs = [
|
|
112 |
]
|
113 |
|
114 |
outputs = [
|
|
|
115 |
gr.Label(label="Result")
|
116 |
]
|
117 |
|
|
|
37 |
(Esta caixa apresenta um detalhamento da avaliação para cada modelo.)
|
38 |
""" }
|
39 |
|
40 |
+
short_score_descriptions = {
|
41 |
+
0: "Not offensive",
|
42 |
+
1: "Offensive"
|
43 |
+
}
|
44 |
+
|
45 |
score_descriptions = {
|
46 |
0: "This text is not offensive.",
|
47 |
1: "This text is offensive.",
|
|
|
101 |
logits = softmax(logits).tolist()
|
102 |
break
|
103 |
def get_description(idx):
|
104 |
+
description = short_score_descriptions[idx]
|
105 |
description_pt = score_descriptions_pt[idx]
|
106 |
final_description = description + "\n \n" + description_pt
|
107 |
return final_description
|
108 |
|
109 |
+
max_pos = logits.index(max(logits))
|
110 |
+
markdown_description = f"# **{short_score_descriptions[max_pos]}** \n \n" + get_description(max_pos)
|
111 |
+
scores = { short_score_descriptions[k]:v for k,v in enumerate(logits) }
|
112 |
|
113 |
+
return markdown_description, scores
|
114 |
|
115 |
|
116 |
inputs = [
|
|
|
119 |
]
|
120 |
|
121 |
outputs = [
|
122 |
+
gr.Markdown(),
|
123 |
gr.Label(label="Result")
|
124 |
]
|
125 |
|