Sm0kyWu commited on
Commit
3a5ea63
ยท
verified ยท
1 Parent(s): beb20dc

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -381,7 +381,7 @@ def add_mask(mask, mask_list):
381
  def vis_mask(image, mask_list):
382
  updated_image = image.copy()
383
  # combine all the mask:
384
- combined_mask = np.zeros_like(updated_image)
385
  for mask in mask_list:
386
  combined_mask = cv2.bitwise_or(combined_mask, mask)
387
  # overlay the mask on the image
@@ -390,23 +390,8 @@ def vis_mask(image, mask_list):
390
 
391
 
392
  with gr.Blocks(delete_cache=(600, 600)) as demo:
393
- # gr.Markdown("""
394
- # ## 3D Amodal Reconstruction with [Amodal3R](https://sm0kywu.github.io/Amodal3R/)
395
- # * Upload an image and click "Generate" to create a 3D asset.
396
- # * Target object selection. Multiple point prompts are supported until you get the ideal visible area.
397
- # * Occluders selection, this can be done by squential point prompts. You can choose "all occ", then all the other areas except the target object will be treated as occluders.
398
- # * Different random seeds can be tried in "Generation Settings", if you think the results are not ideal.
399
- # * If the reconstruction 3D asset is satisfactory, you can extract the GLB file and download it.
400
- # """)
401
  gr.Markdown("""
402
- ## 3D Amodal Reconstruction with [Amodal3R](https://sm0kywu.github.io/Amodal3R/)
403
- * Step 1 - Generate Visibility Mask and Occlusion Mask.
404
- * Please wait for a few seconds after uploading the image. The 2D segmenter is getting ready.
405
- * Add the point prompts to indicate the target object and occluders separately.
406
- * "Render Point", see the position of the point to be added.
407
- * "Add Point", the point will be added to the list.
408
- * "Generate mask", see the segmented area corresponding to current point list.
409
- * "Add mask", current mask will be added for 3D amodal completion.
410
  """)
411
 
412
  # ๅฎšไน‰ๅ„็Šถๆ€ๅ˜้‡
@@ -421,6 +406,14 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
421
 
422
 
423
  with gr.Row():
 
 
 
 
 
 
 
 
424
  with gr.Column():
425
  input_image = gr.Image(type="numpy", label='Input Occlusion Image', sources="upload", height=300)
426
  with gr.Row():
@@ -464,7 +457,17 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
464
  render_occ_mask = gr.Button("Render Mask")
465
  undo_occ_mask = gr.Button("Undo Last Mask")
466
  #
467
-
 
 
 
 
 
 
 
 
 
 
468
  # ---------------------------
469
  # ๅŽŸๆœ‰ไบคไบ’้€ป่พ‘๏ผˆ็•ฅ๏ผ‰
470
  # ---------------------------
@@ -538,7 +541,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
538
  render_vis_mask.click(
539
  vis_mask,
540
  inputs=[original_image, visibility_mask_list],
541
- outputs=[input_image]
542
  )
543
  gen_occ_mask.click(
544
  segment_and_overlay,
@@ -553,7 +556,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
553
  render_occ_mask.click(
554
  vis_mask,
555
  inputs=[original_image, occlusion_mask_list],
556
- outputs=[input_image]
557
  )
558
 
559
 
 
381
  def vis_mask(image, mask_list):
382
  updated_image = image.copy()
383
  # combine all the mask:
384
+ combined_mask = np.zeros_like(mask_list[0])
385
  for mask in mask_list:
386
  combined_mask = cv2.bitwise_or(combined_mask, mask)
387
  # overlay the mask on the image
 
390
 
391
 
392
  with gr.Blocks(delete_cache=(600, 600)) as demo:
 
 
 
 
 
 
 
 
393
  gr.Markdown("""
394
+ ## 3D Amodal Reconstruction with [Amodal3R](https://sm0kywu.github.io/Amodal3R/)
 
 
 
 
 
 
 
395
  """)
396
 
397
  # ๅฎšไน‰ๅ„็Šถๆ€ๅ˜้‡
 
406
 
407
 
408
  with gr.Row():
409
+ gr.Markdown("""* Step 1 - Generate Visibility Mask and Occlusion Mask.
410
+ * Please wait for a few seconds after uploading the image. The 2D segmenter is getting ready.
411
+ * Add the point prompts to indicate the target object and occluders separately.
412
+ * "Render Point", see the position of the point to be added.
413
+ * "Add Point", the point will be added to the list.
414
+ * "Generate mask", see the segmented area corresponding to current point list.
415
+ * "Add mask", current mask will be added for 3D amodal completion.
416
+ """)
417
  with gr.Column():
418
  input_image = gr.Image(type="numpy", label='Input Occlusion Image', sources="upload", height=300)
419
  with gr.Row():
 
457
  render_occ_mask = gr.Button("Render Mask")
458
  undo_occ_mask = gr.Button("Undo Last Mask")
459
  #
460
+ with gr.Row():
461
+ gr.Markdown("""* Step 2 - 3D Amodal Completion.
462
+ * Please first check the obtained mask, and make sure there is no "GAP" between the visible area (white) and occluded area (gray).
463
+ * Different random seeds can be tried in "Generation Settings", if you think the results are not ideal.
464
+ * If the reconstruction 3D asset is satisfactory, you can extract the GLB file and download it.
465
+ """)
466
+ with gr.Column():
467
+ combined_mask = gr.Image(label='Combined Mask', interactive=False, height=300)
468
+ with gr.Row():
469
+ check_combine_button = gr.Button("Check Combined Mask")
470
+
471
  # ---------------------------
472
  # ๅŽŸๆœ‰ไบคไบ’้€ป่พ‘๏ผˆ็•ฅ๏ผ‰
473
  # ---------------------------
 
541
  render_vis_mask.click(
542
  vis_mask,
543
  inputs=[original_image, visibility_mask_list],
544
+ outputs=[visible_mask]
545
  )
546
  gen_occ_mask.click(
547
  segment_and_overlay,
 
556
  render_occ_mask.click(
557
  vis_mask,
558
  inputs=[original_image, occlusion_mask_list],
559
+ outputs=[occluded_mask]
560
  )
561
 
562