Tobias Cornille commited on
Commit
528505f
1 Parent(s): c25f2ae

Fix output + deps

Browse files
Files changed (2) hide show
  1. app.py +7 -9
  2. requirements.txt +1 -0
app.py CHANGED
@@ -371,7 +371,11 @@ def generate_panoptic_mask(
371
  # overlay thing mask on panoptic inds
372
  panoptic_inds[thing_mask.squeeze()] = ind
373
  ind += 1
374
- return panoptic_inds
 
 
 
 
375
 
376
 
377
  ckpt_repo_id = "ShilongLiu/GroundingDINO"
@@ -400,7 +404,7 @@ clipseg_model = CLIPSegForImageSegmentation.from_pretrained(
400
 
401
 
402
  if __name__ == "__main__":
403
- parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
404
  parser.add_argument("--debug", action="store_true", help="using debug mode")
405
  parser.add_argument("--share", action="store_true", help="share the app")
406
  args = parser.parse_args()
@@ -459,9 +463,7 @@ if __name__ == "__main__":
459
  )
460
 
461
  with gr.Column():
462
- gallery = gr.outputs.Image(
463
- type="pil",
464
- ).style(full_width=True, full_height=True)
465
 
466
  run_button.click(
467
  fn=generate_panoptic_mask,
@@ -479,8 +481,4 @@ if __name__ == "__main__":
479
  )
480
  # task_type.change(fn=change_task_type, inputs=[task_type], outputs=[inpaint_prompt])
481
 
482
- DESCRIPTION = "### This demo from [Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything). Thanks for their excellent work."
483
- DESCRIPTION += f'<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/yizhangliu/Grounded-Segment-Anything?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>'
484
- gr.Markdown(DESCRIPTION)
485
-
486
  block.launch(server_name="0.0.0.0", debug=args.debug, share=args.share)
 
371
  # overlay thing mask on panoptic inds
372
  panoptic_inds[thing_mask.squeeze()] = ind
373
  ind += 1
374
+
375
+ fig = plt.figure()
376
+ plt.imshow(image)
377
+ plt.imshow(colorize(panoptic_inds), alpha=0.5)
378
+ return fig
379
 
380
 
381
  ckpt_repo_id = "ShilongLiu/GroundingDINO"
 
404
 
405
 
406
  if __name__ == "__main__":
407
+ parser = argparse.ArgumentParser("Panoptic Segment Anything demo", add_help=True)
408
  parser.add_argument("--debug", action="store_true", help="using debug mode")
409
  parser.add_argument("--share", action="store_true", help="share the app")
410
  args = parser.parse_args()
 
463
  )
464
 
465
  with gr.Column():
466
+ gr.Plot()
 
 
467
 
468
  run_button.click(
469
  fn=generate_panoptic_mask,
 
481
  )
482
  # task_type.change(fn=change_task_type, inputs=[task_type], outputs=[inpaint_prompt])
483
 
 
 
 
 
484
  block.launch(server_name="0.0.0.0", debug=args.debug, share=args.share)
requirements.txt CHANGED
@@ -20,3 +20,4 @@ transformers
20
  yapf
21
  segments-ai
22
  scipy
 
 
20
  yapf
21
  segments-ai
22
  scipy
23
+ skimage