blanchon commited on
Commit
5038ad4
·
1 Parent(s): 2e123ce

Add password

Browse files
Files changed (1) hide show
  1. app.py +18 -26
app.py CHANGED
@@ -434,9 +434,16 @@ css = r"""
434
  """
435
 
436
 
 
 
 
 
 
 
437
  with gr.Blocks(css=css) as demo:
438
  gr.Markdown(intro_markdown)
439
- with gr.Row():
 
440
  with gr.Column(elem_id="col-left"):
441
  gr.HTML(
442
  """
@@ -518,11 +525,7 @@ with gr.Blocks(css=css) as demo:
518
  )
519
  run_button = gr.Button("Run")
520
  flag_button = gr.Button("Flag")
521
- # Reset the results when the run button is clicked
522
- run_button.click(
523
- outputs=results,
524
- fn=lambda: None,
525
- )
526
  with gr.Accordion("Advanced Settings", open=False):
527
  seed = gr.Slider(
528
  label="Seed",
@@ -573,6 +576,15 @@ with gr.Blocks(css=css) as demo:
573
  value=20,
574
  )
575
 
 
 
 
 
 
 
 
 
 
576
  # This needs to be called at some point prior to the first call to callback.flag()
577
  callback.setup(
578
  [
@@ -600,26 +612,6 @@ with gr.Blocks(css=css) as demo:
600
  examples_per_page=12,
601
  )
602
 
603
- run_button.click(
604
- fn=infer,
605
- inputs=[
606
- furniture_image_input,
607
- room_image_input,
608
- furniture_prompt,
609
- seed,
610
- randomize_seed,
611
- guidance_scale,
612
- num_inference_steps,
613
- max_dimension,
614
- num_images_per_prompt,
615
- ],
616
- outputs=[results, seed],
617
- )
618
- flag_button.click(
619
- fn=flag,
620
- inputs=[furniture_image_input, room_image_input, results],
621
- preprocess=False,
622
- )
623
 
624
  # demo.launch(auth=[(USER, PASSWORD)])
625
  demo.launch()
 
434
  """
435
 
436
 
437
+ def check_password(password: str) -> bool:
438
+ if password == PASSWORD:
439
+ return [gr.update(visible=False), gr.update(visible=True)]
440
+ return [gr.update(visible=True), gr.update(visible=False)]
441
+
442
+
443
  with gr.Blocks(css=css) as demo:
444
  gr.Markdown(intro_markdown)
445
+
446
+ with gr.Row(visible=False) as content:
447
  with gr.Column(elem_id="col-left"):
448
  gr.HTML(
449
  """
 
525
  )
526
  run_button = gr.Button("Run")
527
  flag_button = gr.Button("Flag")
528
+
 
 
 
 
529
  with gr.Accordion("Advanced Settings", open=False):
530
  seed = gr.Slider(
531
  label="Seed",
 
576
  value=20,
577
  )
578
 
579
+ with gr.Row():
580
+ password = gr.Textbox(label="Password", type="password")
581
+ submit = gr.Button("Submit")
582
+ submit.click(
583
+ fn=check_password,
584
+ inputs=[password],
585
+ outputs=[submit, content],
586
+ )
587
+
588
  # This needs to be called at some point prior to the first call to callback.flag()
589
  callback.setup(
590
  [
 
612
  examples_per_page=12,
613
  )
614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
 
616
  # demo.launch(auth=[(USER, PASSWORD)])
617
  demo.launch()