Spaces:
Runtime error
Runtime error
VictorSanh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -213,8 +213,8 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
|
|
213 |
g = gr.Button(value="G", min_width=1)
|
214 |
h = gr.Button(value="H", min_width=1)
|
215 |
with gr.Row():
|
216 |
-
model_prediction.render()
|
217 |
user_prediction.render()
|
|
|
218 |
solution = gr.TextArea(
|
219 |
label="Solution",
|
220 |
visible=False,
|
@@ -225,7 +225,21 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
|
|
225 |
with gr.Row():
|
226 |
result.render()
|
227 |
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
load_new_sample.click(
|
230 |
fn=load_sample,
|
231 |
inputs=[],
|
@@ -246,7 +260,7 @@ with gr.Blocks(title="Beat the AI", theme=gr.themes.Base(), css=css) as demo:
|
|
246 |
inputs=[imagebox],
|
247 |
outputs=[model_prediction],
|
248 |
).then(
|
249 |
-
fn=
|
250 |
inputs=[model_prediction, user_prediction, solution],
|
251 |
outputs=[result],
|
252 |
)
|
|
|
213 |
g = gr.Button(value="G", min_width=1)
|
214 |
h = gr.Button(value="H", min_width=1)
|
215 |
with gr.Row():
|
|
|
216 |
user_prediction.render()
|
217 |
+
model_prediction.render()
|
218 |
solution = gr.TextArea(
|
219 |
label="Solution",
|
220 |
visible=False,
|
|
|
225 |
with gr.Row():
|
226 |
result.render()
|
227 |
|
228 |
+
def result_string(model_pred, user_pred, solution):
|
229 |
+
solution_letter = chr(ord('A') + int(z))
|
230 |
+
solution_string = f"The correct answer is f{solution_letter}."
|
231 |
+
|
232 |
+
win_or_loose = "π₯" if user_pred == solution_letter else "π"
|
233 |
+
|
234 |
+
if user_pred == solution_letter and model_pred == solution_letter:
|
235 |
+
comparison_string = "Both you and the AI got it correctly!"
|
236 |
+
elif user_pred == solution_letter and model_pred != solution_letter:
|
237 |
+
comparison_string = "You beat the AI!"
|
238 |
+
elif user_pred != solution_letter and model_pred != solution_letter:
|
239 |
+
comparison_string = "Both you and the AI got it wrong!"
|
240 |
+
|
241 |
+
return f"{win_or_loose} {comparison_string}\n{solution_string}"
|
242 |
+
|
243 |
load_new_sample.click(
|
244 |
fn=load_sample,
|
245 |
inputs=[],
|
|
|
260 |
inputs=[imagebox],
|
261 |
outputs=[model_prediction],
|
262 |
).then(
|
263 |
+
fn=result_string,
|
264 |
inputs=[model_prediction, user_prediction, solution],
|
265 |
outputs=[result],
|
266 |
)
|