Home

Awesome

Propagate Yourself: Exploring Pixel-Level Consistency for Unsupervised Visual Representation Learning

By Zhenda Xie*, Yutong Lin*, Zheng Zhang, Yue Cao, Stephen Lin and Han Hu.

This repo is an official implementation of "Propagate Yourself: Exploring Pixel-Level Consistency for Unsupervised Visual Representation Learning" on PyTorch.

Introduction

PixPro (pixel-to-propagation) is an unsupervised visual feature learning approach by leveraging pixel-level pretext tasks. The learnt feature can be well transferred to downstream dense prediction tasks such as object detection and semantic segmentation. PixPro achieves the best transferring performance on Pascal VOC object detection (60.2 AP using C4) and COCO object detection (41.4 / 40.5 mAP using FPN / C4) with a ResNet-50 backbone.

<div align="center"> <img src="demo/github_teaser.png" height="300px" /> <p>An illustration of the proposed <b><em>PixPro</em></b> method.</p> </div> <div align="center"> <img src="demo/github_pixpro_pipeline.png" height="160px" /> <p>Architecture of the <b><em>PixContrast</em></b> and <b><em>PixPro</em></b> methods.</p> </div>

Citation

@article{xie2020propagate,
  title={Propagate Yourself: Exploring Pixel-Level Consistency for Unsupervised Visual Representation Learning},
  author={Xie, Zhenda and Lin, Yutong and Zhang, Zheng and Cao, Yue and Lin, Stephen and Hu, Han},
  conference={IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
  year={2021}
}

Main Results

PixPro pre-trained models

EpochsArchInstance BranchDownload
100ResNet-50script | model
400ResNet-50script | model
100ResNet-50:heavy_check_mark:-
400ResNet-50:heavy_check_mark:-

Pascal VOC object detection

Faster-RCNN with C4

MethodEpochsArchAPAP<sub>50</sub>AP<sub>75</sub>Download
Scratch-ResNet-5033.860.233.1-
Supervised100ResNet-5053.581.358.8-
MoCo200ResNet-5055.981.562.6-
SimCLR1000ResNet-5056.381.962.5-
MoCo v2800ResNet-5057.682.764.4-
InfoMin200ResNet-5057.682.764.6-
InfoMin800ResNet-5057.582.564.0-
PixPro (ours)100ResNet-5058.883.066.5config | model
PixPro (ours)400ResNet-5060.283.867.7config | model

COCO object detection

Mask-RCNN with FPN

MethodEpochsArchSchedulebbox APmask APDownload
Scratch-ResNet-501x32.829.9-
Supervised100ResNet-501x39.735.9-
MoCo200ResNet-501x39.435.6-
SimCLR1000ResNet-501x39.835.9-
MoCo v2800ResNet-501x40.436.4-
InfoMin200ResNet-501x40.636.7-
InfoMin800ResNet-501x40.436.6-
PixPro (ours)100ResNet-501x40.836.8config | model
PixPro (ours)100*ResNet-501x41.337.1-
PixPro (ours)400*ResNet-501x41.437.4-

* Indicates methods with instance branch.

Mask-RCNN with C4

MethodEpochsArchSchedulebbox APmask APDownload
Scratch-ResNet-501x26.429.3-
Supervised100ResNet-501x38.233.3-
MoCo200ResNet-501x38.533.6-
SimCLR1000ResNet-501x38.433.6-
MoCo v2800ResNet-501x39.534.5-
InfoMin200ResNet-501x39.034.1-
InfoMin800ResNet-501x38.833.8-
PixPro (ours)100ResNet-501x40.034.8config | model
PixPro (ours)400ResNet-501x40.535.3config | model

Getting started

Requirements

At present, we have not checked the compatibility of the code with other versions of the packages, so we only recommend the following configuration.

Installation

We recommand using conda env to setup the experimental environments.

# Create environment
conda create -n PixPro python=3.7 -y
conda activate PixPro

# Install PyTorch & Torchvision
conda install pytorch=1.4.0 cudatoolkit=10.1 torchvision -c pytorch -y

# Install apex
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
cd ..

# Clone repo
git clone https://github.com/zdaxie/PixPro ./PixPro
cd ./PixPro

# Create soft link for data
mkdir data
ln -s ${ImageNet-Path} ./data/imagenet

# Install other requirements
pip install -r requirements.txt

Pretrain with PixPro

# Train with PixPro base for 100 epochs.
./tools/pixpro_base_r50_100ep.sh

Transfer to Pascal VOC or COCO object detection

# Convert a pre-trained PixPro model to detectron2's format
cd transfer/detection
python convert_pretrain_to_d2.py ${Input-Checkpoint(.pth)} ./output.pkl  

# Install Detectron2
python -m pip install detectron2==0.2.1 -f \
  https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.4/index.html

# Create soft link for data
mkdir datasets
ln -s ${Pascal-VOC-Path}/VOC2007 ./datasets/VOC2007
ln -s ${Pascal-VOC-Path}/VOC2012 ./datasets/VOC2012
ln -s ${COCO-Path} ./datasets/coco

# Train detector with pre-trained PixPro model
# 1. Train Faster-RCNN with Pascal-VOC
python train_net.py --config-file configs/Pascal_VOC_R_50_C4_24k_PixPro.yaml --num-gpus 8 MODEL.WEIGHTS ./output.pkl
# 2. Train Mask-RCNN-FPN with COCO
python train_net.py --config-file configs/COCO_R_50_FPN_1x_PixPro.yaml --num-gpus 8 MODEL.WEIGHTS ./output.pkl
# 3. Train Mask-RCNN-C4 with COCO
python train_net.py --config-file configs/COCO_R_50_C4_1x_PixPro.yaml --num-gpus 8 MODEL.WEIGHTS ./output.pkl

# Test detector with provided fine-tuned model
python train_net.py --config-file configs/Pascal_VOC_R_50_C4_24k_PixPro.yaml --num-gpus 8 --eval-only \
  MODEL.WEIGHTS ./pixpro_base_r50_100ep_voc_md5_ec2dfa63.pth

More models and logs will be released!

Acknowledgement

Our testbed builds upon several existing publicly available codes. Specifically, we have modified and integrated the following code into this project:

Contributing to the project

Any pull requests or issues are welcomed.