Home

Awesome

Zero-shot panoptic segmentation using SAM

<a target="_blank" href="https://colab.research.google.com/github/segments-ai/panoptic-segment-anything/blob/master/panoptic-segment-anything.ipynb"> <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> </a> <a target="_blank" href="https://huggingface.co/spaces/segments/panoptic-segment-anything"> <img src="https://camo.githubusercontent.com/00380c35e60d6b04be65d3d94a58332be5cc93779f630bcdfc18ab9a3a7d3388/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f25463025394625413425393725323048756767696e67253230466163652d5370616365732d626c7565" alt="Open In Colab"/> </a>

This is a proof of concept for zero-shot panoptic segmentation using the Segment Anything Model (SAM).

SAM cannot immediately achieve panoptic segmentation due to two limitations:

To solve these challenges we use the following additional models:

You can try out the pipeline by running the notebook in Colab or by trying out the Gradio demo on Hugging Face Spaces.

The notebook also shows how the predictions from this pipeline can be uploaded to Segments.ai as pre-labels, where you can adjust them to obtain perfect labels for fine-tuning your segmentation model.

🖼️Results

Results

🏗️ Pipeline

Our Frankenstein-ish pipeline looks as follows:

  1. Use Grounding DINO to detect the "thing" categories (categories with instances) Step 1
  2. Get instance segmentation masks for the detected boxes using SAM Step 2
  3. Use CLIPSeg to obtain rough segmentation masks of the "stuff" categories Step 3
  4. Sample points in these rough segmentation masks and feed these to SAM to get fine segmentation masks Step 4a Step 4b
  5. Combine the background "stuff" masks with the foreground "thing" masks to obtain a panoptic segmentation label Step 5

💘 Acknowledgements