Adam Jirkovsky commited on
Commit
a355da4
·
1 Parent(s): 460b4ea

Add captcha refresh

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -14,6 +14,7 @@ from src.display.about import (
14
  TABLE_DESC,
15
  )
16
  from src.display.css_html_js import custom_css
 
17
  from src.display.utils import (
18
  BENCHMARK_COLS,
19
  COLS,
@@ -164,10 +165,11 @@ def generate_captcha(width=200, height=150, length=4):
164
  return image, text
165
 
166
 
167
- def validate_captcha(input, text):
168
  if input == text:
169
- return True, "Correct!"
170
- return False, "Incorrect! Please re-enter the code."
 
171
 
172
 
173
 
@@ -357,23 +359,24 @@ with demo:
357
  captcha_result = gr.Markdown()
358
  check_button.click(
359
  fn = validate_captcha,
360
- inputs = [captcha_input, text],
361
- outputs = [captcha_correct, captcha_result],
362
- )
363
- submit_button = gr.Button("Submit Eval", interactive=True)
364
- submission_result = gr.Markdown()
365
- submit_button.click(
366
- fn = add_new_eval,
367
- inputs = [
368
- model_name_textbox,
369
- file_input,
370
- precision,
371
- hf_model_id,
372
- contact_email
373
- ],
374
- outputs = [submission_result, model_name_textbox, precision, hf_model_id, contact_email],
375
  )
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  with gr.Row():
378
  with gr.Accordion("📙 Citation", open=False):
379
  citation_button = gr.Textbox(
 
14
  TABLE_DESC,
15
  )
16
  from src.display.css_html_js import custom_css
17
+ from src.display.formatting import styled_error, styled_message, styled_warning
18
  from src.display.utils import (
19
  BENCHMARK_COLS,
20
  COLS,
 
165
  return image, text
166
 
167
 
168
+ def validate_captcha(input, text, img):
169
  if input == text:
170
+ return True, styled_message("Correct!"), text, img
171
+ img.value, text.value = generate_captcha()
172
+ return False, styled_error("Incorrect! Please retry with the new code."), text, img
173
 
174
 
175
 
 
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],
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  )
365
 
366
+ submit_button = gr.Button("Submit Eval", interactive=True)
367
+ submission_result = gr.Markdown()
368
+ submit_button.click(
369
+ fn = add_new_eval,
370
+ inputs = [
371
+ model_name_textbox,
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
+ )
379
+
380
  with gr.Row():
381
  with gr.Accordion("📙 Citation", open=False):
382
  citation_button = gr.Textbox(