Deformable DETR

repository·main·Indexed 26 days ago

https://github.com/fundamentalvision/deformable-detr

An efficient, fast-converging end-to-end object detector that utilizes a sampling-based attention mechanism to improve upon the original DETR architecture, specifically for small object detection. The repository includes instructions for compiling custom CUDA operators, preparing the COCO 2017 dataset, and training across single nodes, multiple nodes, or Slurm clusters.

Tokens
766
Snippets
2
Records
9
Agent score
38%

What's inside Deformable DETR

  1. Compile CUDA operators

    main

    Deformable DETR requires compiling custom CUDA operators. Navigate to the models/ops directory, run the build script, and then verify the installation with the provided unit test. A successful installation should result in all checks returning True.

    cd ./models/ops
    sh ./make.sh
    # unit test (should see all checking is True)
    python test.py
  2. Install Deformable DETR

    main

    To install Deformable DETR, ensure your system meets the following requirements:

    • OS/Hardware: Linux, CUDA >= 9.2, GCC >= 5.4
    • Python: >= 3.7
    • PyTorch: >= 1.5.1, torchvision >= 0.6.1

    Follow these steps to set up the environment using Anaconda:

    1. Create and activate a conda environment.
    2. Install PyTorch and torchvision (example for CUDA 9.2).
    3. Install additional dependencies via requirements.txt.
  3. Prepare COCO 2017 dataset

    main

    To use the COCO 2017 dataset for training or evaluation, download it and organize your directory structure as follows:

    code_root/
    └── data/
        └── coco/
            ├── train2017/
            ├── val2017/
            └── annotations/
            	├── instances_train2017.json
            	└── instances_val2017.json
  4. Train Deformable DETR on multiple nodes

    main
    For multi-node training, use run_dist_launch.sh on each node. You must provide the MASTER_ADDR (IP of node 1) and the NODE_RANK (0 for the first node, 1 for the second, etc.) for each node. The total number of GPUs across all nodes should be passed as the first argument.
  5. Configure Deformable DETR training and evaluation via CLI

    main

    The main.py script serves as the entrypoint for training and evaluating Deformable DETR models. It uses argparse to manage a wide range of hyperparameters for the backbone, transformer, loss functions, and dataset loading.

    Key configuration categories include:

    • Optimizer/Learning Rate: Control --lr, --lr_backbone, --lr_linear_proj_mult, and switch to SGD using --sgd.
    • Model Architecture: Select --backbone (e.g., resnet50), set --num_feature_levels, and configure transformer layers via --enc_layers and --dec_layers.
    • Training Control: Set --epochs, --batch_size, --output_dir, and --resume to load checkpoints.
    • Task Variants: Enable segmentation with --masks or use --two_stage / --with_box_refine variants.
    • Dataset: Specify --dataset_file (e.g., coco) and --coco_path.