README.md

January 30, 2022 ยท View on GitHub

(NOTICE) All the ReXNet-lite's model files have been updated!

(NOTICE) Our paper has been accepted at CVPR 2021!! The paper has been updated at arxiv!

Rethinking Channel Dimensions for Efficient Model Design

Dongyoon Han, Sangdoo Yun, Byeongho Heo, and YoungJoon Yoo | Paper | Pretrained Models

NAVER AI Lab

Abstract

Designing an efficient model within the limited computational cost is challenging. We argue the accuracy of a lightweight model has been further limited by the design convention: a stage-wise configuration of the channel dimensions, which looks like a piecewise linear function of the network stage. In this paper, we study an effective channel dimension configuration towards better performance than the convention. To this end, we empirically study how to design a single layer properly by analyzing the rank of the output feature. We then investigate the channel configuration of a model by searching network architectures concerning the channel configuration under the computational cost restriction. Based on the investigation, we propose a simple yet effective channel configuration that can be parameterized by the layer index. As a result, our proposed model following the channel parameterization achieves remarkable performance on ImageNet classification and transfer learning tasks including COCO object detection, COCO instance segmentation, and fine-grained classifications.

Model performance

  • We first illustrate our models' top-acc. vs. computational costs graphs compared with EfficientNets

<img src=https://user-images.githubusercontent.com/31481676/113254746-f0416500-9301-11eb-9cd8-f188037cc82c.png width=2000 hspace=20>

Performance comparison

ReXNets vs EfficientNets

  • The CPU latencies are tested on Xeon E5-2630_v4 with a single image and the GPU latencies are measured on a V100 GPU with the batchsize of 64.

  • EfficientNets' scores are taken form arxiv v3 of the paper.

    ModelInput Res.Top-1 acc.Top-5 acc.FLOPs/params.CPU Lat./ GPU Lat.
    ReXNet_0.9224x22477.293.50.35B/4.1M45ms/20ms
    EfficientNet-B0224x22477.393.50.39B/5.3M47ms/23ms
    ReXNet_1.0224x22477.993.90.40B/4.8M47ms/21ms
    EfficientNet-B1240x24079.294.50.70B/7.8M70ms/37ms
    ReXNet_1.3224x22479.594.70.66B/7.6M55ms/28ms
    EfficientNet-B2260x26080.395.01.0B/9.2M77ms/48ms
    ReXNet_1.5224x22480.395.20.88B/9.7M59ms/31ms
    EfficientNet-B3300x30081.795.61.8B/12M100ms/78ms
    ReXNet_2.0224x22481.695.71.8B/19M69ms/40ms

ReXNet-lites vs. EfficientNet-lites

  • ReXNet-lites do not use SE-net an SiLU activations aiming to faster training and inference speed.

  • We compare ReXNet-lites with EfficientNet-lites.

  • Here the GPU latencies are measured on two M40 GPUs, we will update the number run on a V100 GPU soon.

    ModelInput Res.Top-1 acc.Top-5 acc.FLOPs/paramsCPU Lat./ GPU Lat.
    EfficientNet-lite0224x22475.1-0.41B/4.7M30ms/49ms
    ReXNet-lite_1.0224x22476.292.80.41B/4.7M31ms/49ms
    EfficientNet-lite1240x24076.7-0.63B/5.4M44ms/73ms
    ReXNet-lite_1.3224x22477.893.80.65B/6.8M36ms/61ms
    EfficientNet-lite2260x26077.6-0.90B/ 6.1M48ms/93ms
    ReXNet-lite_1.5224x22478.694.20.84B/8.3M39ms/68ms
    EfficientNet-lite3280x28079.8-1.4B/ 8.2M60ms/131ms
    ReXNet-lite_2.0224x22480.295.01.5B/13M49ms/90ms

ImageNet-1k Pretrained models

ImageNet classification results

  • Please refer the following pretrained models. Top-1 and top-5 accuraies are reported with the computational costs.

  • Note that all the models are trained and evaluated with 224x224 image size.

    ModelInput Res.Top-1 acc.Top-5 acc.FLOPs/params
    ReXNet_1.0224x22477.993.90.40B/4.8M
    ReXNet_1.3224x22479.594.70.66B/7.6M
    ReXNet_1.5224x22480.395.20.88B/9.7M
    ReXNet_2.0224x22481.695.71.5B/16M
    ReXNet_3.0224x22482.896.23.4B/34M
    ReXNet-lite_1.0224x22476.292.80.41B/4.7M
    ReXNet-lite_1.3224x22477.893.80.65B/6.8M
    ReXNet-lite_1.5224x22478.694.20.84B/8.3M
    ReXNet-lite_2.0224x22480.295.01.5B/13M

Finetuning results

COCO Object detection

  • The following results are trained with Faster RCNN with FPN:

    BackboneImg. SizeB_AP (%)B_AP_0.5 (%)B_AP_0.75 (%)Params.FLOPsEval. set
    FBNet-C-FPN1200x80035.157.437.221.4M119.0Bval2017
    EfficientNetB0-FPN1200x80038.060.140.421.0M123.0Bval2017
    ReXNet_0.9-FPN1200x80038.060.640.820.1M123.0Bval2017
    ReXNet_1.0-FPN1200x80038.560.641.520.7M124.1Bval2017
    ResNet50-FPN1200x80037.658.240.941.8M202.2Bval2017
    ResNeXt-101-FPN1200x80040.362.144.160.4M272.4Bval2017
    ReXNet_2.2-FPN1200x80041.564.044.933.0M153.8Bval2017

COCO instance segmentation

  • The following results are trained with Mask RCNN with FPN, S_AP and B_AP denote segmentation AP and box AP, respectively:

    BackboneImg. SizeS_AP (%)S_AP_0.5 (%)S_AP_0.75 (%)B_AP (%)B_AP_0.5 (%)B_AP_0.75 (%)Params.FLOPsEval. set
    EfficientNetB0_FPN1200x80034.856.836.638.460.240.823.7M123.0Bval2017
    ReXNet_0.9-FPN1200x80035.257.437.138.760.841.622.8M123.0Bval2017
    ReXNet_1.0-FPN1200x80035.457.737.438.961.142.123.3M124.1Bval2017
    ResNet50-FPN1200x80034.655.936.838.559.041.644.2M207Bval2017
    ReXNet_2.2-FPN1200x80037.861.040.242.064.545.635.6M153.8Bval2017

Getting Started

Requirements

  • Python3
  • PyTorch (> 1.0)
  • Torchvision (> 0.2)
  • NumPy

Using the pretrained models

  • timm>=0.3.0 provides the wonderful wrap-up of ours models thanks to Ross Wightman. Otherwise, the models can be loaded as follows:

    • To use ReXNet on a GPU:
    import torch
    import rexnetv1
    
    model = rexnetv1.ReXNetV1(width_mult=1.0).cuda()
    model.load_state_dict(torch.load('./rexnetv1_1.0.pth'))
    model.eval()
    print(model(torch.randn(1, 3, 224, 224).cuda()))
    
    • To use ReXNet-lite on a CPU:
    import torch
    import rexnetv1_lite
    
    model = rexnetv1_lite.ReXNetV1_lite(multiplier=1.0)
    model.load_state_dict(torch.load('./rexnet_lite_1.0.pth', map_location=torch.device('cpu')))
    model.eval()
    print(model(torch.randn(1, 3, 224, 224)))
    
    

Training own ReXNet

ReXNet can be trained with any PyTorch training codes including ImageNet training in PyTorch with the model file and proper arguments. Since the provided model file is not complicated, we simply convert the model to train a ReXNet in other frameworks like MXNet. For MXNet, we recommend MXnet-gluoncv as a training code.

Using PyTorch, we trained ReXNets with one of the popular imagenet classification code, Ross Wightman's pytorch-image-models for more efficient training. After including ReXNet's model file into the training code, one can train ReXNet-1.0x with the following command line:

./distributed_train.sh 4 /imagenet/ --model rexnetv1 --rex-width-mult 1.0 --opt sgd --amp \
 --lr 0.5 --weight-decay 1e-5 \
 --batch-size 128 --epochs 400 --sched cosine \
 --remode pixel --reprob 0.2 --drop 0.2 --aa rand-m9-mstd0.5 
 

Using droppath or MixUP may need to train a bigger model.

License

This project is distributed under MIT license.

How to cite

@misc{han2021rethinking,
      title={Rethinking Channel Dimensions for Efficient Model Design}, 
      author={Dongyoon Han and Sangdoo Yun and Byeongho Heo and YoungJoon Yoo},
      year={2021},
      eprint={2007.00992},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}