CenterNet Framework

repository·master·Indexed 27 days ago

https://github.com/xingyizhou/centernet

An end-to-end differentiable framework for object detection, 3D detection, and pose estimation that models objects as single center points to avoid NMS post-processing. It includes support for tasks such as ctdet (object detection) and multi_pose (human pose estimation), and provides implementations for Deformable Convolutional Networks V2 (DCNv2) and Deformable ROI Pooling (DCNPooling) in PyTorch. The framework supports datasets including COCO, Pascal VOC, and KITTI.

Tokens
8.7K
Snippets
24
Records
53
Agent score
92%

What's inside CenterNet

  1. Train CenterNet models

    master

    Training is performed using main.py. Detailed experiment configurations are located in the experiments/ folder.

    Key Arguments:

    • --exp_id: The experiment identifier (matches model names in the model zoo).
    • --batch_size: Total batch size.
    • --master_batch: Batch size for the master GPU (useful if the master GPU has more memory or if you need to adjust for memory constraints).
    • --gpus: Comma-separated list of GPU IDs (e.g., 0,1).
    • --lr: Learning rate. If using fewer than 8 GPUs, scale the learning rate according to the linear learning rate rule.
    • --resume: Resumes training from the latest model with the same --exp_id.

    Example (COCO DLA on 2 GPUs):

    python main.py ctdet --exp_id coco_dla --batch_size 32 --master_batch 15 --lr 1.25e-4 --gpus 0,1
  2. Prepare the KITTI dataset

    master

    To prepare KITTI for CenterNet, follow these steps:

    1. Download and unzip images, annotations, and calibrations from the KITTI website.
    2. Download the train-val splits for 3DOP and SubCNN and place them in ${CenterNet_ROOT}/data/kitti/ following the required structure (including ImageSets_3dop and ImageSets_subcnn).
    3. Convert annotations to COCO format by running python convert_kitti_to_coco.py in the tools directory. You can set DEBUG=True on line 5 of this script to visualize annotations.
    4. Link the image folder using the following commands:
    cd ${CenterNet_ROOT}/data/kitti/
    mkdir images
    ln -s training/image_2 images/trainval

    Final structure should be:

    • annotations/: contains kitti_3dop_train.json, kitti_3dop_val.json, kitti_subcnn_train.json, and kitti_subcnn_val.json.
    • images/: contains trainval and test folders.
  3. Download pre-trained models from the Model Zoo

    master

    Pre-trained models for Object Detection (COCO, Pascal VOC), Human Pose Estimation (COCO), and 3D Bounding Box Detection (KITTI) can be downloaded directly from the official Google Drive repository.

    Environment used for experiments:

    • PyTorch 0.4.1
    • CUDA 9.0
    • CUDNN 7.1
    https://drive.google.com/drive/folders/1S3NnppRgXea_IG4WeyquJcnOB3I6G-LX
  4. Clone and Setup CenterNet Repository

    master

    Clone the repository and install Python dependencies:

    CenterNet_ROOT=/path/to/clone/CenterNet
    git clone https://github.com/xingyizhou/CenterNet $CenterNet_ROOT
    cd $CenterNet_ROOT
    pip install -r requirements.txt
    git clone https://github.com/xingyizhou/CenterNet $CenterNet_ROOT
    pip install -r requirements.txt
  5. Evaluate COCO object detection

    master

    To evaluate COCO object detection, download models to CenterNet_ROOT/models/ and use test.py with the ctdet task.

    DLA Architecture: Use --exp_id coco_dla and --load_model pointing to your DLA checkpoint.

    Hourglass Architecture: Use --arch hourglass and --fix_res.

    Options:

    • --keep_res: Keeps original image resolution (otherwise images are resized to 512 x 512).
    • --flip_test: Enables flip testing.
    • --test_scales <scales>: Enables multi-scale testing (e.g., --test_scales 0.5,0.75,1,1.25,1.5).
  6. Evaluate Pascal VOC object detection

    master

    To evaluate object detection on Pascal VOC (test2007), use the ctdet task with --dataset pascal. Note that resolution is fixed during testing, but you can override it using --input_res.

    python test.py ctdet --exp_id dla --dataset pascal --load_model ../models/ctdet_pascal_dla.pth --flip_test
  7. Run CenterNet Demos

    master

    CenterNet supports demos for images, image folders, videos, and webcams.

    Prerequisites:

    1. Download models from the Model zoo.
    2. Place models in CenterNet_ROOT/models/.

    Task Types:

    • ctdet: Object detection.
    • multi_pose: Human pose estimation.

    Available Flags:

    • --demo: Path to image/folder/video or webcam.
    • --load_model: Path to the .pth model file.
    • --debug 2: Visualize heatmap outputs.
    • --flip_test: Enable flip testing.