:star: Explanations/Tips for Grounding DINO Inputs and Outputs
Grounding DINO accepts an (image, text) pair as inputs.
It outputs 900 (by default) object boxes. Each box has similarity scores across all input words. (as shown in Figures below.)
We defaultly choose the boxes whose highest similarities are higher than a box_threshold.
We extract the words whose similarities are higher than the text_threshold as predicted labels.
If you want to obtain objects of specific phrases, like the dogs in the sentence two dogs with a stick., you can select the boxes with highest text similarities with dogs as final outputs.
Note that each word can be split to more than one tokens with different tokenlizers. The number of words in a sentence may not equal to the number of text tokens.
We suggest separating different category names with . for Grounding DINO.
:label: TODO
Release inference code and demo.
Release checkpoints.
Grounding DINO with Stable Diffusion and GLIGEN demos.
Release training codes.
:hammer_and_wrench: Install
Note:
If you have a CUDA environment, please make sure the environment variable CUDA_HOME is set. It will be compiled under CPU-only mode if no CUDA available.
Replace {GPU ID}, image_you_want_to_detect.jpg, and "dir you want to save the output" with appropriate values in the following command
CUDA_VISIBLE_DEVICES={GPU ID} python demo/inference_on_a_image.py \
-c /GroundingDINO/groundingdino/config/GroundingDINO_SwinT_OGC.py \
-p /GroundingDINO/weights/groundingdino_swint_ogc.pth \
-i image_you_want_to_detect.jpg \
-o "dir you want to save the output" \
-t "chair"
[--cpu-only] # open it for cpu mode
See the demo/inference_on_a_image.py for more details.
Marrying Grounding DINO with Stable Diffusion for Image Editing
See our example notebook for more details.
Marrying Grounding DINO with GLIGEN for more Detailed Image Editing.
See our example notebook for more details.
:sauropod: Model: Grounding DINO
Includes: a text backbone, an image backbone, a feature enhancer, a language-guided query selection, and a cross-modality decoder.
:hearts: Acknowledgement
Our model is related to DINO and GLIP. Thanks for their great work!
We also thank great previous work including DETR, Deformable DETR, SMCA, Conditional DETR, Anchor DETR, Dynamic DETR, DAB-DETR, DN-DETR, etc. More related work are available at Awesome Detection Transformer. A new toolbox detrex is available as well.
If you find our work helpful for your research, please consider citing the following BibTeX entry.
@article{liu2023grounding,
title={Grounding dino: Marrying dino with grounded pre-training for open-set object detection},
author={Liu, Shilong and Zeng, Zhaoyang and Ren, Tianhe and Li, Feng and Zhang, Hao and Yang, Jie and Li, Chunyuan and Yang, Jianwei and Su, Hang and Zhu, Jun and others},
journal={arXiv preprint arXiv:2303.05499},
year={2023}
}
Works well with
Use together with groundingdino-py: extensions, drivers, servers and companion tools.
torchPythie’s Index: 89Tensors and Dynamic neural networks in Python with strong GPU acceleration59.1M downloads/mo
transformersPythie’s Index: 90Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.122.3M downloads/mo
sahiPythie’s Index: 92A vision library for performing sliced inference on large images/small objects143.1K downloads/mo