Spaces:
Running
Running
Update game3.py
Browse files
game3.py
CHANGED
@@ -40,9 +40,9 @@ def func3(num_selected, human_predict, num1, num2, user_important):
|
|
40 |
interpretation = eval(content[int(num_selected*2+1)])
|
41 |
|
42 |
if text['binary_label'] == 1:
|
43 |
-
golden_label = int(
|
44 |
else:
|
45 |
-
golden_label = int(
|
46 |
|
47 |
# (START) off-the-shelf version -- slow at the beginning
|
48 |
# Load model directly
|
@@ -58,9 +58,9 @@ def func3(num_selected, human_predict, num1, num2, user_important):
|
|
58 |
# (END) off-the-shelf version
|
59 |
|
60 |
if out['label'] == 'Female':
|
61 |
-
ai_predict = int(
|
62 |
else:
|
63 |
-
ai_predict =
|
64 |
|
65 |
user_select = "You focused on "
|
66 |
flag_select = False
|
@@ -80,20 +80,20 @@ def func3(num_selected, human_predict, num1, num2, user_important):
|
|
80 |
# user_select += "nothing. Interesting! "
|
81 |
user_select += "Wanna see how the AI made the guess? Click here. β¬
οΈ"
|
82 |
|
83 |
-
if golden_label >
|
84 |
gender = ' (female)'
|
85 |
-
elif golden_label <
|
86 |
gender = ' (male)'
|
87 |
else:
|
88 |
gender = ' (neutral)'
|
89 |
|
90 |
-
if abs(golden_label - human_predict) <=
|
91 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Congratulations! π Both of you get the correct answer!", user_select))
|
92 |
num1 += 1
|
93 |
num2 += 1
|
94 |
-
elif abs(golden_label - human_predict) >
|
95 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Sorry.. No one gets the correct answer. But nice try! π", user_select))
|
96 |
-
elif abs(golden_label - human_predict) <=
|
97 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Great! π You are closer to the answer and better than AI!", user_select))
|
98 |
num1 += 1
|
99 |
else:
|
@@ -102,10 +102,6 @@ def func3(num_selected, human_predict, num1, num2, user_important):
|
|
102 |
|
103 |
tot_scores = ''' ### <p style="text-align: center;"> π€ Machine   ''' + str(int(num2)) + '''   VS   ''' + str(int(num1)) + '''   Human π¨π© </p>'''
|
104 |
|
105 |
-
|
106 |
-
num_tmp = max(num1, num2)
|
107 |
-
y_lim_upper = (int((num_tmp + 3)/10)+1) * 10
|
108 |
-
|
109 |
return ai_predict, chatbot, num1, num2, tot_scores
|
110 |
|
111 |
def interpre3(num_selected):
|
@@ -165,11 +161,11 @@ def func3_written(text_written, human_predict, lang_written):
|
|
165 |
# (END) off-the-shelf version
|
166 |
|
167 |
if out['label'] == 'Female':
|
168 |
-
ai_predict = int(
|
169 |
else:
|
170 |
-
ai_predict =
|
171 |
|
172 |
-
if abs(ai_predict - human_predict) <=
|
173 |
chatbot.append(("AI gives it a close score! π", "β¬
οΈ Feel free to try another one! β¬
οΈ"))
|
174 |
else:
|
175 |
chatbot.append(("AI thinks in a different way from human. π", "β¬
οΈ Feel free to try another one! β¬
οΈ"))
|
|
|
40 |
interpretation = eval(content[int(num_selected*2+1)])
|
41 |
|
42 |
if text['binary_label'] == 1:
|
43 |
+
golden_label = int(5 * (1 - text['binary_score']))
|
44 |
else:
|
45 |
+
golden_label = int(5 * (1 + text['binary_score']))
|
46 |
|
47 |
# (START) off-the-shelf version -- slow at the beginning
|
48 |
# Load model directly
|
|
|
58 |
# (END) off-the-shelf version
|
59 |
|
60 |
if out['label'] == 'Female':
|
61 |
+
ai_predict = int(10 * out['score'])
|
62 |
else:
|
63 |
+
ai_predict = 10 - int(10 * out['score'])
|
64 |
|
65 |
user_select = "You focused on "
|
66 |
flag_select = False
|
|
|
80 |
# user_select += "nothing. Interesting! "
|
81 |
user_select += "Wanna see how the AI made the guess? Click here. β¬
οΈ"
|
82 |
|
83 |
+
if golden_label > 6:
|
84 |
gender = ' (female)'
|
85 |
+
elif golden_label < 4:
|
86 |
gender = ' (male)'
|
87 |
else:
|
88 |
gender = ' (neutral)'
|
89 |
|
90 |
+
if abs(golden_label - human_predict) <= 2 and abs(golden_label - ai_predict) <= 2:
|
91 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Congratulations! π Both of you get the correct answer!", user_select))
|
92 |
num1 += 1
|
93 |
num2 += 1
|
94 |
+
elif abs(golden_label - human_predict) > 2 and abs(golden_label - ai_predict) > 2:
|
95 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Sorry.. No one gets the correct answer. But nice try! π", user_select))
|
96 |
+
elif abs(golden_label - human_predict) <= 2 and abs(golden_label - ai_predict) > 2:
|
97 |
chatbot.append(("The correct answer is " + str(golden_label) + gender + ". Great! π You are closer to the answer and better than AI!", user_select))
|
98 |
num1 += 1
|
99 |
else:
|
|
|
102 |
|
103 |
tot_scores = ''' ### <p style="text-align: center;"> π€ Machine   ''' + str(int(num2)) + '''   VS   ''' + str(int(num1)) + '''   Human π¨π© </p>'''
|
104 |
|
|
|
|
|
|
|
|
|
105 |
return ai_predict, chatbot, num1, num2, tot_scores
|
106 |
|
107 |
def interpre3(num_selected):
|
|
|
161 |
# (END) off-the-shelf version
|
162 |
|
163 |
if out['label'] == 'Female':
|
164 |
+
ai_predict = int(10 * out['score'])
|
165 |
else:
|
166 |
+
ai_predict = 10 - int(10 * out['score'])
|
167 |
|
168 |
+
if abs(ai_predict - human_predict) <= 2:
|
169 |
chatbot.append(("AI gives it a close score! π", "β¬
οΈ Feel free to try another one! β¬
οΈ"))
|
170 |
else:
|
171 |
chatbot.append(("AI thinks in a different way from human. π", "β¬
οΈ Feel free to try another one! β¬
οΈ"))
|