Adam Jirkovsky
commited on
Commit
·
daf8b12
1
Parent(s):
4ac8818
Minor adjustments
Browse files- app.py +22 -27
- src/submission/submit.py +3 -3
app.py
CHANGED
@@ -168,8 +168,8 @@ def generate_captcha(width=200, height=150, length=4):
|
|
168 |
def validate_captcha(input, text, img):
|
169 |
img, new_text = generate_captcha()
|
170 |
if input == text:
|
171 |
-
return True, styled_message("Correct! You can procede with your submission"), new_text, img
|
172 |
-
return False, styled_error("Incorrect! Please retry with the new code."), new_text, img
|
173 |
|
174 |
|
175 |
|
@@ -342,31 +342,26 @@ with demo:
|
|
342 |
#upload_button = gr.UploadButton("Upload json", file_types=['.json'])
|
343 |
#upload_button.upload(validate_upload, upload_button, file_input)
|
344 |
|
345 |
-
with gr.
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
inputs = [captcha_input, text, captcha_img],
|
366 |
-
outputs = [captcha_correct, captcha_result, text, captcha_img],
|
367 |
-
)
|
368 |
-
with gr.Column():
|
369 |
-
pass
|
370 |
|
371 |
submit_button = gr.Button("Submit Eval", interactive=True)
|
372 |
submission_result = gr.Markdown()
|
|
|
168 |
def validate_captcha(input, text, img):
|
169 |
img, new_text = generate_captcha()
|
170 |
if input == text:
|
171 |
+
return True, styled_message("Correct! You can procede with your submission."), new_text, img, ""
|
172 |
+
return False, styled_error("Incorrect! Please retry with the new code."), new_text, img, ""
|
173 |
|
174 |
|
175 |
|
|
|
342 |
#upload_button = gr.UploadButton("Upload json", file_types=['.json'])
|
343 |
#upload_button.upload(validate_upload, upload_button, file_input)
|
344 |
|
345 |
+
with gr.Group():
|
346 |
+
captcha_correct = gr.State(False)
|
347 |
+
text = gr.State("")
|
348 |
+
image, text.value = generate_captcha()
|
349 |
+
captcha_img = gr.Image(
|
350 |
+
image,
|
351 |
+
label="Prove your humanity",
|
352 |
+
interactive=False,
|
353 |
+
show_download_button=False,
|
354 |
+
show_fullscreen_button=False,
|
355 |
+
show_share_button=False,
|
356 |
+
)
|
357 |
+
captcha_input = gr.Textbox(placeholder="Enter the text in the image above", show_label=False, container=False)
|
358 |
+
check_button = gr.Button("Validate", interactive=True)
|
359 |
+
captcha_result = gr.Markdown()
|
360 |
+
check_button.click(
|
361 |
+
fn = validate_captcha,
|
362 |
+
inputs = [captcha_input, text, captcha_img],
|
363 |
+
outputs = [captcha_correct, captcha_result, text, captcha_img, captcha_input],
|
364 |
+
)
|
|
|
|
|
|
|
|
|
|
|
365 |
|
366 |
submit_button = gr.Button("Submit Eval", interactive=True)
|
367 |
submission_result = gr.Markdown()
|
src/submission/submit.py
CHANGED
@@ -32,9 +32,6 @@ def add_new_eval(
|
|
32 |
captcha_ok: bool,
|
33 |
):
|
34 |
try:
|
35 |
-
if not captcha_ok:
|
36 |
-
return styled_error("Please prove you are a human!")
|
37 |
-
|
38 |
if not eval_name:
|
39 |
return styled_error("Please provide a model name.")
|
40 |
|
@@ -47,6 +44,9 @@ def add_new_eval(
|
|
47 |
if not upload:
|
48 |
return styled_error("Please upload a results file.")
|
49 |
|
|
|
|
|
|
|
50 |
with open(upload, mode="r") as f:
|
51 |
data = json.load(f)
|
52 |
|
|
|
32 |
captcha_ok: bool,
|
33 |
):
|
34 |
try:
|
|
|
|
|
|
|
35 |
if not eval_name:
|
36 |
return styled_error("Please provide a model name.")
|
37 |
|
|
|
44 |
if not upload:
|
45 |
return styled_error("Please upload a results file.")
|
46 |
|
47 |
+
if not captcha_ok:
|
48 |
+
return styled_error("Please prove you are a human!")
|
49 |
+
|
50 |
with open(upload, mode="r") as f:
|
51 |
data = json.load(f)
|
52 |
|