Home

Awesome

DynamicDet [arXiv]

This repo contains the official implementation of "DynamicDet: A Unified Dynamic Architecture for Object Detection".

<div align="center"> <a href="./"> <img src="./figure/performance.png" width="50%"/> </a> </div>

Performance

MS COCO

ModelEasy / HardSizeFLOPsFPSAP<sup>val</sup>AP<sup>test</sup>
Dy-YOLOv790% / 10%640112.4G11051.4%52.1%
50% / 50%640143.2G9652.7%53.3%
10% / 90%640174.0G8553.3%53.8%
0% / 100%640181.7G8353.5%53.9%
Dy-YOLOv7-X90% / 10%640201.7G9853.0%53.3%
50% / 50%640248.9G7854.2%54.4%
10% / 90%640296.1G6554.7%55.0%
0% / 100%640307.9G6454.8%55.0%
Dy-YOLOv7-W690% / 10%1280384.2G7454.9%55.2%
50% / 50%1280480.8G5855.9%56.1%
10% / 90%1280577.4G4856.4%56.7%
0% / 100%1280601.6G4656.5%56.8%
<details> <summary> Table Notes </summary> </details>

Quick Start

Installation

cd DynamicDet
conda install pytorch=1.11 cudatoolkit=11.3 torchvision -c pytorch
pip install -r requirements.txt

Data preparation

Download MS COCO dataset images (train, val, test) and labels.

├── coco
│   ├── train2017.txt
│   ├── val2017.txt
│   ├── test-dev2017.txt
│   ├── images
│   │   ├── train2017
│   │   ├── val2017
│   │   ├── test2017
│   ├── labels
│   │   ├── train2017
│   │   ├── val2017
│   ├── annotations
│   │   ├── instances_val2017.json

Training

Step1: Training cascaded detector

Step2: Training adaptive router

python train_step2.py --workers 4 --device 0 --batch-size 1 --epochs 2 --img 640 --adam --cfg cfg/dy-yolov7-step2.yaml --weight runs/train/dy-yolov7-step1/weights/last.pt --data data/coco.yaml --hyp hyp/hyp.finetune.dynamic.adam.yaml --name dy-yolov7-step2

Getting the dynamic thresholds for variable-speed inference

python get_dynamic_thres.py --device 0 --batch-size 1 --img-size 640 --cfg cfg/dy-yolov7-step2.yaml --weight weights/dy-yolov7.pt --data data/coco.yaml --task val

Testing

python test.py --img-size 640 --batch-size 1 --conf 0.001 --iou 0.65 --device 0 --cfg cfg/dy-yolov7-step2.yaml --weight weights/dy-yolov7.pt --data data/coco.yaml --dy-thres <DY_THRESHOLD>

Inference

python detect.py --cfg cfg/dy-yolov7-step2.yaml --weight weights/dy-yolov7.pt --num-classes 80 --source <IMAGE/VIDEO> --device 0 --dy-thres <DY_THRESHOLD>

Citation

If you find this repo useful in your research, please consider citing the following paper:

@inproceedings{lin2023dynamicdet,
  title={DynamicDet: A Unified Dynamic Architecture for Object Detection},
  author={Lin, Zhihao and Wang, Yongtao and Zhang, Jinhe and Chu, Xiaojie},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2023}
}

License

The project is only free for academic research purposes, but needs authorization for commerce. For commerce permission, please contact wyt@pku.edu.cn.