Skip to content

Auto Segmentation label generation with SAM (Segment Anything) + Grounding DINO

License

Notifications You must be signed in to change notification settings

mhyeonsoo/SAM_gDINO_AutoLabeling

Repository files navigation

SAM_gDINO_AutoLabeling

Auto Segmentation label generation with SAM (Segment Anything) + Grounding DINO

How To Use

1. Requirements

  • You should set the environment variable manually as follows if you want to build a local GPU environment for Grounded-SAM first.
export AM_I_DOCKER=False
export BUILD_WITH_CUDA=True
export CUDA_HOME=/path/to/cuda-11.3/
  • Install Segment Anything:
python -m pip install -e segment_anything
  • Install Grounding DINO:
python -m pip install -e GroundingDINO
  • Install diffusers:
pip install --upgrade diffusers[torch]
  • These are necessary packages which may be required to run post-processes
pip install opencv-python pycocotools matplotlib onnxruntime onnx ipykernel

2. How to Run the Label generation scripts.

1. Download the pretrained weights

# download the pretrained groundingdino-swin-tiny model
wget https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth
# move downloaded model to ./weights directory

2. Run the jupyter notebook

Auto-Label-Generation is a notebook for generating labels

- Format of generated annotation

1. Yolov8
2. COCO

3. Custom configs / arguments

To get the labels for your custom image inputs, we need to modify these in the Auto-Label-Generation notebook.

1. text prompt input for grounding DINO
TEXT_PROMPT = "[classes of custom dataset]" 
# (for multi-class, you can add . between each class --> 'class1 . class2 . class3')
2. category list for COCO annotation
CAT_ID = {'class1': 1, 'class2': 2, 'class3': 3, 'class4': 4, 'class5': 5, 'class6': 6}
# COCO category list is in form of a python dictionary

Aknowledgements

About

Auto Segmentation label generation with SAM (Segment Anything) + Grounding DINO

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages