Dense Contrastive Learning for Self-Supervised Visual Pre-Training

December 11, 2023 ยท View on GitHub

Here we provide instructions and results for applying DenseCL pre-trained models to AdelaiDet. Please refer to https://git.io/DenseCL for the pre-training code.

Dense Contrastive Learning for Self-Supervised Visual Pre-Training,
Xinlong Wang, Rufeng Zhang, Chunhua Shen, Tao Kong, Lei Li
In: Proc. IEEE Conf. Computer Vision and Pattern Recognition (CVPR), 2021, Oral
arXiv preprint (arXiv 2011.09157)

Installation

First, follow the default instruction to install the project and datasets/README.md set up the datasets (e.g., MS-COCO).

DenseCL Pre-trained Models

pre-train methodpre-train datasetbackbone#epochLink
DenseCLCOCOResNet-50800download
DenseCLCOCOResNet-501600download
DenseCLImageNetResNet-50200download
DenseCLImageNetResNet-101200download

Usage

Download the pre-trained model

PRETRAIN_DIR=./
wget https://cloudstor.aarnet.edu.au/plus/s/hdAg5RYm8NNM2QP/download -O ${PRETRAIN_DIR}/densecl_r50_imagenet_200ep.pkl

Convert it to detectron2's format

Use convert-pretrain-to-detectron2.py to convert the pre-trained backbone weights:

WEIGHT_FILE=${PRETRAIN_DIR}/densecl_r50_imagenet_200ep.pth
OUTPUT_FILE=${PRETRAIN_DIR}/densecl_r50_imagenet_200ep.pkl
python convert-pretrain-to-detectron2.py ${WEIGHT_FILE} ${OUTPUT_FILE}

Train the downstream models

For training a SOLOv2, run:

OMP_NUM_THREADS=1 python tools/train_net.py \
    --config-file configs/DenseCL/SOLOv2_R50_1x_DenseCL.yaml \
    --num-gpus 8 \
    OUTPUT_DIR training_dir/SOLOv2_R50_1x_DenseCL \
    MODEL.WEIGHTS ${PRETRAIN_DIR}/densecl_r50_imagenet_200ep.pkl

For training a FCOS, run:

OMP_NUM_THREADS=1 python tools/train_net.py \
    --config-file configs/DenseCL/FCOS_R50_1x_DenseCL.yaml \
    --num-gpus 8 \
    OUTPUT_DIR training_dir/FCOS_R50_1x_DenseCL \
    MODEL.WEIGHTS ${PRETRAIN_DIR}/densecl_r50_imagenet_200ep.pkl

Performance

SOLOv2 on COCO Instance Segmentation

pre-train methodpre-train datasetmask AP
SupervisedImageNet35.2
MoCo-v2ImageNet35.2
DenseCLImageNet35.7 (+0.5)

FCOS on COCO Object Detection

pre-train methodpre-train datasetbox AP
SupervisedImageNet39.9
MoCo-v2ImageNet40.3
DenseCLImageNet40.9 (+1.0)

Citation

Please consider citing our paper in your publications if the project helps your research. BibTeX reference is as follows.

@inproceedings{wang2020densecl,
  title     =   {Dense Contrastive Learning for Self-Supervised Visual Pre-Training},
  author    =   {Wang, Xinlong and Zhang, Rufeng and Shen, Chunhua and Kong, Tao and Li, Lei},
  booktitle =   {Proc. IEEE Conf. Computer Vision and Pattern Recognition (CVPR)},
  year      =   {2021}
}