2023-03-24 10:07:02 +08:00
# Grounding DINO
---
[](https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/zero-shot-object-detection-with-grounding-dino.ipynb)
2023-03-10 15:26:21 +08:00
[](https://paperswithcode.com/sota/zero-shot-object-detection-on-mscoco?p=grounding-dino-marrying-dino-with-grounded) \
[](https://paperswithcode.com/sota/zero-shot-object-detection-on-odinw?p=grounding-dino-marrying-dino-with-grounded) \
[](https://paperswithcode.com/sota/object-detection-on-coco-minival?p=grounding-dino-marrying-dino-with-grounded) \
[](https://paperswithcode.com/sota/object-detection-on-coco?p=grounding-dino-marrying-dino-with-grounded)
2023-03-24 10:07:02 +08:00
2023-03-21 12:56:05 +08:00
Official pytorch implementation of [Grounding DINO ](https://arxiv.org/abs/2303.05499 ), a stronger open-set object detector. Code is available now!
2023-03-10 15:26:21 +08:00
## Highlight
2023-03-24 10:07:02 +08:00
2023-03-16 10:54:29 +08:00
- **Open-Set Detection.** Detect **everything** with language!
- **High Performancce.** COCO zero-shot **52.5 AP** (training without COCO data!). COCO fine-tune **63.0 AP** .
- **Flexible.** Collaboration with Stable Diffusion for Image Editting.
2023-03-10 15:26:21 +08:00
2023-03-16 11:57:00 +08:00
<!-- [](https://youtu.be/wxWDt5UiwY8)
< iframe width = "560" height = "315" src = "https://youtu.be/wxWDt5UiwY8" frameborder = "0" allow = "autoplay; encrypted-media" allowfullscreen > < / iframe > -->
2023-03-10 15:26:21 +08:00
2023-03-16 11:57:00 +08:00
< details open >
2023-03-16 11:52:42 +08:00
< summary > < font size = "4" >
Description
< / font > < / summary >
< img src = ".asset/hero_figure.png" alt = "ODinW" width = "100%" >
< / details >
2023-03-10 15:26:21 +08:00
2023-03-24 10:07:02 +08:00
## TODO
2023-03-21 12:52:46 +08:00
2023-03-21 12:56:05 +08:00
- [x] Release inference code and demo.
- [x] Release checkpoints.
- [ ] Grounding DINO with Stable Diffusion and GLIGEN demos.
2023-03-21 12:52:46 +08:00
2023-03-24 10:07:02 +08:00
## Install
2023-03-21 12:52:46 +08:00
If you have a CUDA environment, please make sure the environment variable `CUDA_HOME` is set.
2023-03-24 10:07:02 +08:00
2023-03-21 12:52:46 +08:00
```bash
pip install -e .
```
2023-03-24 10:07:02 +08:00
## Demo
2023-03-21 12:52:46 +08:00
See the `demo/inference_on_a_image.py` for more details.
```bash
CUDA_VISIBLE_DEVICES=6 python demo/inference_on_a_image.py \
-c /path/to/config \
-p /path/to/checkpoint \
-i .asset/cats.png \
-o "outputs/0" \
-t "cat ear."
```
2023-03-24 10:07:02 +08:00
## Checkpoints
2023-03-21 12:52:46 +08:00
<!-- insert a table -->
< table >
< thead >
< tr style = "text-align: right;" >
< th > < / th >
< th > name< / th >
< th > backbone< / th >
< th > Data< / th >
< th > box AP on COCO< / th >
< th > Checkpoint< / th >
< / tr >
< / thead >
< tbody >
< tr >
< th > 1< / th >
< td > GroundingDINO-T< / td >
< td > Swin-T< / td >
< td > O365,GoldG,Cap4M< / td >
< td > 48.4 (zero-shot) / 57.2 (fine-tune)< / td >
< td > < a href = "https://github.com/IDEA-Research/GroundingDINO/releases/download/v0.1.0-alpha/groundingdino_swint_ogc.pth" > link< / a > < / td >
< / tr >
< / tbody >
< / table >
2023-03-16 10:54:29 +08:00
## Results
2023-03-24 10:07:02 +08:00
2023-03-16 10:54:29 +08:00
< details open >
< summary > < font size = "4" >
COCO Object Detection Results
< / font > < / summary >
< img src = ".asset/COCO.png" alt = "COCO" width = "100%" >
< / details >
< details open >
< summary > < font size = "4" >
ODinW Object Detection Results
< / font > < / summary >
< img src = ".asset/ODinW.png" alt = "ODinW" width = "100%" >
< / details >
< details open >
< summary > < font size = "4" >
Marrying Grounding DINO with < a href = "https://github.com/Stability-AI/StableDiffusion" > Stable Diffusion< / a > for Image Editing
< / font > < / summary >
< img src = ".asset/GD_SD.png" alt = "GD_SD" width = "100%" >
< / details >
< details open >
< summary > < font size = "4" >
Marrying Grounding DINO with < a href = "https://github.com/gligen/GLIGEN" > GLIGEN< / a > for more Detailed Image Editing
< / font > < / summary >
< img src = ".asset/GD_GLIGEN.png" alt = "GD_GLIGEN" width = "100%" >
< / details >
2023-03-10 15:26:21 +08:00
## Model
Includes: a text backbone, an image backbone, a feature enhancer, a language-guided query selection, and a cross-modality decoder.
2023-03-10 15:29:26 +08:00

2023-03-10 15:26:21 +08:00
2023-03-24 10:07:02 +08:00
## Acknowledgement
2023-03-10 15:26:21 +08:00
Our model is related to [DINO ](https://github.com/IDEA-Research/DINO ) and [GLIP ](https://github.com/microsoft/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 ](https://github.com/IDEACVR/awesome-detection-transformer ). A new toolbox [detrex ](https://github.com/IDEA-Research/detrex ) is available as well.
2023-03-16 10:54:29 +08:00
Thanks [Stable Diffusion ](https://github.com/Stability-AI/StableDiffusion ) and [GLIGEN ](https://github.com/gligen/GLIGEN ) for their awesome models.
2023-03-10 15:26:21 +08:00
2023-03-24 10:07:02 +08:00
## Citation
2023-03-10 15:26:21 +08:00
If you find our work helpful for your research, please consider citing the following BibTeX entry.
2023-03-24 10:07:02 +08:00
2023-03-10 15:26:21 +08:00
```bibtex
@inproceedings {ShilongLiu2023GroundingDM,
title={Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection},
author={Shilong Liu and Zhaoyang Zeng and Tianhe Ren and Feng Li and Hao Zhang and Jie Yang and Chunyuan Li and Jianwei Yang and Hang Su and Jun Zhu and Lei Zhang},
year={2023}
}
```