Home

Awesome

CLD: Unsupervised Feature Learning by Cross-Level Instance-Group Discrimination.

by Xudong Wang, Ziwei Liu and Stella X. Yu at UC Berkeley / ICSI and NTU.

<em>IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2021.</em>

<p align="center"> <img src="http://people.eecs.berkeley.edu/~xdwang/projects/CLD/CLD.png" width="60%" > </p>

For more information, please check: Project Page | PDF | Preprint | BibTex

Updates

[06/08/2021] Training and linear evaluating InfoMin + CLD on ImageNet is supported.

[05/20/2021] Training and linear evaluating MoCo v2 + CLD on ImageNet is supported.

[04/12/2021] Training MoCo + CLD on CIFAR is supported now.

[04/09/2021] Initial Commit. Training NPID + CLD on CIFAR is avaliable now in this repo. We also plan to support MoCo+CLD, BYOL+CLD and InfoMin+CLD.

Requirements

Packages

Dataset Preparation

CIFAR and STL-10 code will download data automatically with the dataloader. For ImageNet, please download the ImageNet-1k dataset from here. Moving validation images to labeled subfolders using the following script is required: valprep.sh. For ImageNet-100, it was firstly used in CMC and contains 100 categories of ImageNet. The category list of ImageNet-100 can be found in data/imagenet100.txt. Please organize ImageNet-100 according to the following structure. For high-correlation dataset Kitchen-HC, it is constructed by extracting objects in their bounding boxes from the multi-view RGB-D Kitchen dataset. Kitchen-HC can be downloaded from this link.

data
├── CIFAR-10
│   └── cifar-10-batches-py
│       ├── batches.meta
│       ├── data_batch_1
│       ├── ...
│       ├── data_batch_5
│       └── test_batch
├── CIFAR-100
│   └── cifar-100-python
│       ├── file.txt~
│       ├── meta
│       ├── train
│       └── test
├── Kitchen-HC
│   ├── train
│   │   ├── n02869837
│   │   ├── ...
│   │   └── n02090622
│   └── test
│       ├── n02869837
│       ├── ...
│       └── n02090622
├── ImageNet-100
│   ├── train
│   │   ├── n02869837
│   │   ├── ...
│   │   └── n02090622
│   └── val
│       ├── n02869837
│       ├── ...
│       └── n02090622
└── ImageNet
    ├── train
    │   ├── n01440764
    │   ├── ...
    │   └── n15075141
    └── val
        ├── n01440764
        ├── ...
        └── n15075141

Training and Evaluation Instructions

CIFAR-10 and CIFAR-100

NPID + CLD

bash scripts/train_cifar10_npid_cld.sh or bash scripts/train_cifar100_npid_cld.sh
MethodProjection HeadCIFAR-10CIFAR-100
NPIDLinear80.851.6
NPID+CLD (reported)Linear86.757.5
NPID+CLD (reproduced)Linear86.858.8

The model is trained with mixed precision (fp16) by default, it is necessary to install apex if you want to apply mixed precision training. The reproduced result is the average kNN accuracies of 3 runs.

MoCo + CLD

bash scripts/train_cifar10_moco_cld.sh or bash scripts/train_cifar100_moco_cld.sh
MethodProjection HeadCIFAR-10CIFAR-100
MoCoLinear82.153.1
MoCo+CLD (reported)Linear87.558.1
MoCo+CLD (reproduced)LinearN/A59.1
MoCo+CLD (reproduced)NormLinearN/A59.7

The model is trained with the proposed NormLinear as the projection head by default. Other settings are the same as NPID+CLD.

ImageNet

MoCo v2 + CLD

train

bash scripts/imagenet/train_imagenet_mocov2_cld.sh

linear evaluation

bash scripts/imagenet/test_imagenet_moco_cld.sh
MethodProjection Head#epochsTop-1 (%)Models
MoCov2MLP20067.5-
MoCov2+CLDMLP20069.2link
MoCov2+CLDNormMLP20070.0link

It is necesary to change the DATA_DIR, SAVE_DIR and PRETRAINED_MODEL. All models are pretrained for 200 epochs and evaluated with standard augmentation, linear decay scheduler and SGD optimizer.

InfoMin + CLD

train

bash scripts/imagenet/train_imagenet_infomin_cld.sh

linear evaluation

bash scripts/imagenet/test_imagenet_infomin_cld.sh
MethodProjection Head#epochsTop-1 (%)Models
InfoMinMLP10067.4-
CLDMLP10069.5link
CLDNormMLP10070.1link
CLDMLP20070.6link
CLDNormMLP20071.5link

Please change the DATA_DIR and PRETRAINED_MODEL before launching experiments.

How to get support from us?

If you have any general questions, feel free to email us at xdwang at eecs.berkeley.edu. If you have code or implementation-related questions, please feel free to send emails to us or open an issue in this codebase (We recommend that you open an issue in this codebase, because your questions may help others).

Citation

If you find our work inspiring or use our codebase in your research, please cite our work.

@inproceedings{wang2021unsupervised,
  title={Unsupervised feature learning by cross-level instance-group discrimination},
  author={Wang, Xudong and Liu, Ziwei and Yu, Stella X},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={12586--12595},
  year={2021}
}

License

This project is licensed under the MIT License. See LICENSE for more details. The parts described below follow their original license.

Acknowledgements

Part of this code is based on NPID, MoCo, CMC, infoMin and OpenSelfSup.