Chao Xu commited on
Commit
0c4cb96
β€’
1 Parent(s): bb83e2d

update run_btn and icecream

Browse files
Files changed (3) hide show
  1. app.py +8 -9
  2. demo_tmp/.gitignore +1 -0
  3. requirements.txt +1 -0
app.py CHANGED
@@ -452,7 +452,6 @@ def on_coords_slider(image, x_min, y_min, x_max, y_max, color=(88, 191, 131, 255
452
  print("on_coords_slider, image_size:", np.array(image).shape)
453
  image = cv2.cvtColor(np.array(image), cv2.COLOR_RGBA2BGRA)
454
  image = cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, int(max(max(image.shape) / 400*2, 2)))
455
- print("on_coords_slider, done")
456
  return cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) # image[:, :, ::-1]
457
 
458
  def save_img(image):
@@ -583,14 +582,14 @@ def run_demo(
583
  steps_slider = gr.Slider(5, 200, value=75, step=5,
584
  label='Number of diffusion inference steps')
585
 
586
- with gr.Row():
587
- run_btn = gr.Button('Run Generation', variant='primary')
588
  # guide_title = gr.Markdown(_GUIDE_TITLE, visible=True)
589
  guide_text = gr.Markdown(_USER_GUIDE, visible=True)
590
 
591
- with gr.Row():
592
  # height does not work [a bug]
593
- mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="One-2-3-45's Textured Mesh", elem_id="model-3d-out") #.style(height=800)
594
 
595
  with gr.Row(variant='panel'):
596
  with gr.Column(scale=0.85):
@@ -647,19 +646,19 @@ def run_demo(
647
 
648
  placeholder = gr.Image(visible=False)
649
  tmp_func = lambda x: False if not x else gr.update(visible=False)
650
- disable_func = lambda *args: [gr.update(interactive=False)] * len(args)
651
- enable_func = lambda *args: [gr.update(interactive=True)] * len(args)
652
  image_block.change(fn=refresh,
653
  inputs=[tmp_dir],
654
  outputs=[tmp_dir, rerun_idx, bbox_block, sam_block, elev_output, vis_output, mesh_output, regen_view_btn, regen_mesh_btn, *views, *btn_retrys]
655
- ).success(disable_func, inputs=[run_btn], outputs=[run_btn]
656
  ).success(fn=tmp_func, inputs=[image_block], outputs=[placeholder]
657
  ).success(fn=partial(update_guide, _BBOX_1), outputs=[guide_text]
658
  ).success(fn=save_img,
659
  inputs=[image_block],
660
  outputs=[bbox_block, *bbox_sliders]
661
  ).success(fn=partial(update_guide, _BBOX_3), outputs=[guide_text]
662
- ).success(enable_func, inputs=[run_btn], outputs=[run_btn])
663
 
664
 
665
  for bbox_slider in bbox_sliders:
 
452
  print("on_coords_slider, image_size:", np.array(image).shape)
453
  image = cv2.cvtColor(np.array(image), cv2.COLOR_RGBA2BGRA)
454
  image = cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, int(max(max(image.shape) / 400*2, 2)))
 
455
  return cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) # image[:, :, ::-1]
456
 
457
  def save_img(image):
 
582
  steps_slider = gr.Slider(5, 200, value=75, step=5,
583
  label='Number of diffusion inference steps')
584
 
585
+ # with gr.Row():
586
+ run_btn = gr.Button('Run Generation', variant='primary')
587
  # guide_title = gr.Markdown(_GUIDE_TITLE, visible=True)
588
  guide_text = gr.Markdown(_USER_GUIDE, visible=True)
589
 
590
+ # with gr.Row():
591
  # height does not work [a bug]
592
+ mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="One-2-3-45's Textured Mesh", elem_id="model-3d-out") #.style(height=800)
593
 
594
  with gr.Row(variant='panel'):
595
  with gr.Column(scale=0.85):
 
646
 
647
  placeholder = gr.Image(visible=False)
648
  tmp_func = lambda x: False if not x else gr.update(visible=False)
649
+ disable_func = lambda x: gr.update(interactive=False)
650
+ enable_func = lambda x: gr.update(interactive=True)
651
  image_block.change(fn=refresh,
652
  inputs=[tmp_dir],
653
  outputs=[tmp_dir, rerun_idx, bbox_block, sam_block, elev_output, vis_output, mesh_output, regen_view_btn, regen_mesh_btn, *views, *btn_retrys]
654
+ ).success(disable_func, inputs=run_btn, outputs=run_btn
655
  ).success(fn=tmp_func, inputs=[image_block], outputs=[placeholder]
656
  ).success(fn=partial(update_guide, _BBOX_1), outputs=[guide_text]
657
  ).success(fn=save_img,
658
  inputs=[image_block],
659
  outputs=[bbox_block, *bbox_sliders]
660
  ).success(fn=partial(update_guide, _BBOX_3), outputs=[guide_text]
661
+ ).success(enable_func, inputs=run_btn, outputs=run_btn)
662
 
663
 
664
  for bbox_slider in bbox_sliders:
demo_tmp/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ tmp*
requirements.txt CHANGED
@@ -26,6 +26,7 @@ lovely-numpy>=0.2.8
26
  lovely-tensors>=0.1.14
27
  plotly>=5.13.1
28
  -e git+https://github.com/CompVis/taming-transformers.git#egg=taming-transformers
 
29
  # elev est
30
  dl_ext
31
  easydict
 
26
  lovely-tensors>=0.1.14
27
  plotly>=5.13.1
28
  -e git+https://github.com/CompVis/taming-transformers.git#egg=taming-transformers
29
+ icecream
30
  # elev est
31
  dl_ext
32
  easydict