Home

Awesome

CondenseNetV2

This repository is the official Pytorch implementation for CVPR2021 paper "CondenseNet V2: Sparse Feature Reactivation for Deep Networks" by Le Yang*, Haojun Jiang*, Ruojin Cai, Yulin Wang, Shiji Song, Gao Huang and Qi Tian (*Authors contributed equally).

News

Reference

If you find our project useful in your research, please consider citing:

@inproceedings{yang2021condensenetv2,
  title={CondenseNet V2: Sparse Feature Reactivation for Deep Networks},
  author={Yang, Le and Jiang, Haojun and Cai, Ruojin and Wang, Yulin and Song, Shiji and Huang, Gao and Tian, Qi},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  year={2021}
}

Contents

  1. Introduction
  2. Usage
  3. Results
  4. Contacts
  5. Acknowledgments

Introduction

Reusing features in deep networks through dense connectivity is an effective way to achieve high computational efficiency. The recent proposed CondenseNet has shown that this mechanism can be further improved if redundant features are removed. In this paper, we propose an alternative approach named sparse feature reactivation (SFR), aiming at actively increasing the utility of features for reusing. In the proposed network, named CondenseNetV2, each layer can simultaneously learn to 1) selectively reuse a set of most important features from preceding layers; and 2) actively update a set of preceding features to increase their utility for later layers. Our experiments show that the proposed models achieve promising performance on image classification (ImageNet and CIFAR) and object detection (MS COCO) in terms of both theoretical efficiency and practical speed.

DenseNet, CondenseNet and CondenseNetV2. Comparison

Sparse feature reactivation. SFR

Usage

Dependencies

Training

As an example, use the following command to train a CondenseNetV2-A/B/C on ImageNet

python -m torch.distributed.launch --nproc_per_node=8 train.py --model cdnv2_a/b/c 
  --batch-size 1024 --lr 0.4 --warmup-lr 0.1 --warmup-epochs 5 --opt sgd --sched cosine \
  --epochs 350 --weight-decay 4e-5 --aa rand-m9-mstd0.5 --remode pixel --reprob 0.2 \
  --data_url /PATH/TO/IMAGENET --train_url /PATH/TO/LOG_DIR

Evaluation

We take the ImageNet model trained above as an example.

To evaluate the non-converted trained model, use test.py to evaluate from a given checkpoint path:

python test.py --model cdnv2_a/b/c \
  --data_url /PATH/TO/IMAGENET -b 32 -j 8 \
  --train_url /PATH/TO/LOG_DIR \
  --evaluate_from /PATH/TO/MODEL_WEIGHT

To evaluate the converted trained model, use --model converted_cdnv2_a/b/c:

python test.py --model converted_cdnv2_a/b/c \
  --data_url /PATH/TO/IMAGENET -b 32 -j 8 \
  --train_url /PATH/TO/LOG_DIR \
  --evaluate_from /PATH/TO/MODEL_WEIGHT

Note that these models are still the large models after training. To convert the model to standard group-convolution version as described in the paper, use the convert_and_eval.py:

python convert_and_eval.py --model cdnv2_a/b/c \
  --data_url /PATH/TO/IMAGENET -b 64 -j 8 \
  --train_url /PATH/TO/LOG_DIR \
  --convert_from /PATH/TO/MODEL_WEIGHT

Results

Results on ImageNet

ModelFLOPsParamsTop-1 ErrorConverted ModelUnconverted Model
CondenseNetV2-A46M2.0M35.6Tsinghua Cloud / Google Drive-
CondenseNetV2-B146M3.6M28.1Tsinghua Cloud / Google Drive-
CondenseNetV2-C309M6.1M24.1Tsinghua Cloud / Google DriveTsinghua Cloud / Google Drive

Results on COCO2017 Detection

The detection experiments are conducted based on the mmdetection repository. We simply replace the backbones of FasterRCNN and RetinaNet with our CondenseNetV2s.

Detection FrameworkBackboneBackbone FLOPsmAP
FasterRCNNShuffleNetV2 0.5x41M22.1
FasterRCNNCondenseNetV2-A46M23.5
FasterRCNNShuffleNetV2 1.0x146M27.4
FasterRCNNCondenseNetV2-B146M27.9
FasterRCNNMobileNet 1.0x300M30.6
FasterRCNNShuffleNetV2 1.5x299M30.2
FasterRCNNCondenseNetV2-C309M31.4
RetinaNetMobileNet 1.0x300M29.7
RetinaNetShuffleNetV2 1.5x299M29.1
RetinaNetCondenseNetV2-C309M31.7

Results on CIFAR

ModelFLOPsParamsCIFAR-10CIFAR-100
CondenseNet-5028.6M0.22M6.22-
CondenseNet-7451.9M0.41M5.28-
CondenseNet-8665.8M0.52M5.0623.64
CondenseNet-9881.3M0.65M4.83-
CondenseNet-11098.2M0.79M4.63-
CondenseNet-122116.7M0.95M4.48-
CondenseNetV2-11041M0.48M4.6523.94
CondenseNetV2-14662M0.78M4.3522.52

Contacts

yangle15 at mails.tsinghua.edu.cn

jhj20 at mails.tsinghua.edu.cn

Any discussions or concerns are welcomed!

Acknowledgments

Our work is inspired by CondenseNet: An Efficient DenseNet using Learned Group Convolutions and we use the code in the official repository of CondenseNet.

Thanks to Ross Wightman for building a powerful Pytorch Image Models repository, our training code is forked from his repository.