Home

Awesome

Updates

Oct 27, 2020

Oct 26, 2020

rethinking_bottleneck_design

This repo contains the code for the paper Rethinking Bottleneck Structure for Efficient Mobile Network Design (ECCV 2020)

MobileNeXt(MNEXT) is an light weight models cater for mobile devices. It combines the advantages of traditional ResNet bottleneck building block and the MBV2 inverted residual block. Besides, the newly proposed building block also takes the hardware implementation into consideration such that the memory consumption can be adjusted at algorithm level without minimum impacts on the model performance.

@article{zhou2020rethinking,
  title={Rethinking Bottleneck Structure for Efficient Mobile Network Design},
  author={Zhou, Daquan and Hou, Qibin and Chen, Yunpeng and Feng, Jiashi and Yan, Shuicheng},
  journal={ECCV, August},
  year={2020}
}

The training framework is modified based on an older version(upon release) of the repo pytorch-image-models

Performance

Model performance at different width multiplier:

ModelParam.(M)Madd(M)Top-1 Acc.(%)
MobileNeXt-1.406.159076.1
MobileNeXt-1.003.530074.02
MobileNeXt-0.752.521072
MobileNeXt-0.502.111067.7
MobileNeXt-0.351.88064.7

Latency and accuracy with different tensor multiplier:

ModelTensor multiplierMadd(M)Top-1 Acc.(%)Latency(Pytorch,ms)
MobileNeXt130074.02211
MobileNeXt230074.09196
MobileNeXt330073.91195
MobileNeXt430073.68188

Latency measurement with Pytorch and TF Lite:

ModelPixel 4-CPU(ms)Pixel 4-GPU(ms)Platform
MBV2190 - 220-Pytorch Mobile
Ours191 - 220-Pytorch Mobile
MBV268 - 92-TF Mobile
Ours66 - 91-TF Mobile
MBV244 - 4715 - 17TF Lite
Ours48 - 5116 - 17TF Lite

To reproduce the results in the paper

run the batch script as below: bash mnext_efficient_l.sh # of process

The three scripts are used for the training from scratch.

  1. mnext_efficient_l.sh: MobileNeXt large model based on EfficientNet backbone
  2. mnext_efficient_s.sh: MobileNeXt small model based on EfficientNet backbone
  3. mnext_mbv2.sh: MobileNeXt large model based on MobileNetV2 backbone

To reproduce the latency measurement

TF lite There are four steps to follow: change to mobile deployment folder:

  1. Run the MobileNeXt model tf version to save a checkpoint
  1. convert the checkpoint to mobile graph
  1. generate the freeze graph based on the mobile graph
  1. convert to tf lite model to be loaded by android studio
    import tensorflow.lite as lite

    # Converting a SavedModel.
    saved_model_dir = "./output/model.ckpt-100"
    converter = lite.TFLiteConverter.from_saved_model(saved_model_dir)
    tflite_model = converter.convert()

    open("converted_model.tflite", "wb").write(tflite_model)

After generating the mobile model based on tf lite, copy the model to the assets folder under the android studio project

Code for detection on both Pascal VOC and COCO

Please refer to this repo. Our MobileNeXt improves MobileNetV2 by 1% (from 22.3% to 23.3%) in terms of mAP under the same settings.

To do :

  1. Add in Android project for apk generation