Spaces:
Runtime error
Runtime error
Adam Jirkovsky
commited on
Commit
·
50e453b
1
Parent(s):
a825d33
Submit GUI adjustments
Browse files- app.py +10 -9
- src/submission/submit.py +5 -1
app.py
CHANGED
@@ -166,10 +166,10 @@ def generate_captcha(width=200, height=150, length=4):
|
|
166 |
|
167 |
|
168 |
def validate_captcha(input, text, img):
|
|
|
169 |
if input == text:
|
170 |
-
return True, styled_message("Correct!"),
|
171 |
-
|
172 |
-
return False, styled_error("Incorrect! Please retry with the new code."), text, img
|
173 |
|
174 |
|
175 |
|
@@ -337,10 +337,10 @@ with demo:
|
|
337 |
)
|
338 |
hf_model_id = gr.Textbox(label="Model link (Optional)", info="URL to the model's Hugging Face repository, or it's official website")
|
339 |
contact_email = gr.Textbox(label="Your E-Mail")
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
|
345 |
with gr.Group():
|
346 |
captcha_correct = gr.State(False)
|
@@ -349,7 +349,7 @@ with demo:
|
|
349 |
captcha_img = gr.Image(
|
350 |
image,
|
351 |
label="Prove your humanity",
|
352 |
-
|
353 |
show_download_button=False,
|
354 |
show_fullscreen_button=False,
|
355 |
show_share_button=False,
|
@@ -372,7 +372,8 @@ with demo:
|
|
372 |
file_input,
|
373 |
precision,
|
374 |
hf_model_id,
|
375 |
-
contact_email
|
|
|
376 |
],
|
377 |
outputs = [submission_result, model_name_textbox, precision, hf_model_id, contact_email],
|
378 |
)
|
|
|
166 |
|
167 |
|
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 |
|
|
|
337 |
)
|
338 |
hf_model_id = gr.Textbox(label="Model link (Optional)", info="URL to the model's Hugging Face repository, or it's official website")
|
339 |
contact_email = gr.Textbox(label="Your E-Mail")
|
340 |
+
file_input = gr.File(file_count="single", interactive=True, label="Upload json file with evaluation results")
|
341 |
+
file_input.upload(validate_upload, file_input)
|
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)
|
|
|
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,
|
|
|
372 |
file_input,
|
373 |
precision,
|
374 |
hf_model_id,
|
375 |
+
contact_email,
|
376 |
+
captcha_correct,
|
377 |
],
|
378 |
outputs = [submission_result, model_name_textbox, precision, hf_model_id, contact_email],
|
379 |
)
|
src/submission/submit.py
CHANGED
@@ -28,9 +28,13 @@ def add_new_eval(
|
|
28 |
upload: object,
|
29 |
precision: str,
|
30 |
hf_model_id: str,
|
31 |
-
contact_email: str
|
|
|
32 |
):
|
33 |
try:
|
|
|
|
|
|
|
34 |
with open(upload, mode="r") as f:
|
35 |
data = json.load(f)
|
36 |
|
|
|
28 |
upload: object,
|
29 |
precision: str,
|
30 |
hf_model_id: str,
|
31 |
+
contact_email: str,
|
32 |
+
captcha_ok: bool,
|
33 |
):
|
34 |
try:
|
35 |
+
if not captcha_ok:
|
36 |
+
return styled_error("Please prove you are a human!"), "", "", "", ""
|
37 |
+
|
38 |
with open(upload, mode="r") as f:
|
39 |
data = json.load(f)
|
40 |
|