2023-03-02 13:29:07 +08:00
# Shufflenet V2
2022-01-26 18:26:01 +08:00
2023-03-02 13:29:07 +08:00
> [ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design](https://openaccess.thecvf.com/content_ECCV_2018/papers/Ningning_Light-weight_CNN_Architecture_ECCV_2018_paper.pdf)
2022-06-02 15:22:01 +08:00
2021-11-24 17:23:37 +08:00
<!-- [ALGORITHM] -->
2020-12-18 20:04:54 +08:00
2021-11-24 17:23:37 +08:00
## Abstract
2022-01-26 18:26:01 +08:00
2021-11-24 17:23:37 +08:00
Currently, the neural network architecture design is mostly guided by the *indirect* metric of computation complexity, i.e., FLOPs. However, the *direct* metric, e.g., speed, also depends on the other factors such as memory access cost and platform characterics. Thus, this work proposes to evaluate the direct metric on the target platform, beyond only considering FLOPs. Based on a series of controlled experiments, this work derives several practical *guidelines* for efficient network design. Accordingly, a new architecture is presented, called *ShuffleNet V2* . Comprehensive ablation experiments verify that our model is the state-of-the-art in terms of speed and accuracy tradeoff.
2020-12-18 20:04:54 +08:00
2021-11-24 17:23:37 +08:00
< div align = center >
< img src = "https://user-images.githubusercontent.com/26739999/142576336-e0db2866-3add-44e6-a792-14d4f11bd983.png" width = "80%" / >
< / div >
2021-01-11 11:10:06 +08:00
2023-03-02 13:29:07 +08:00
## How to use it?
2022-01-26 18:26:01 +08:00
2023-03-02 13:29:07 +08:00
<!-- [TABS - BEGIN] -->
2022-01-26 18:26:01 +08:00
2023-03-02 13:29:07 +08:00
**Predict image**
2022-01-26 18:26:01 +08:00
2023-03-02 13:29:07 +08:00
```python
from mmpretrain import inference_model
predict = inference_model('shufflenet-v2-1x_16xb64_in1k', 'demo/bird.JPEG')
print(predict['pred_class'])
print(predict['pred_score'])
```
**Use the model**
```python
import torch
from mmpretrain import get_model
model = get_model('shufflenet-v2-1x_16xb64_in1k', pretrained=True)
inputs = torch.rand(1, 3, 224, 224)
out = model(inputs)
print(type(out))
# To extract features.
feats = model.extract_feat(inputs)
print(type(feats))
```
**Train/Test Command**
2023-04-06 20:58:52 +08:00
Prepare your dataset according to the [docs ](https://mmpretrain.readthedocs.io/en/latest/user_guides/dataset_prepare.html#prepare-dataset ).
2023-03-02 13:29:07 +08:00
Train:
2022-01-26 18:26:01 +08:00
2023-03-02 13:29:07 +08:00
```shell
python tools/train.py configs/shufflenet_v2/shufflenet-v2-1x_16xb64_in1k.py
2022-01-26 18:26:01 +08:00
```
2023-03-02 13:29:07 +08:00
Test:
```shell
python tools/test.py configs/shufflenet_v2/shufflenet-v2-1x_16xb64_in1k.py https://download.openmmlab.com/mmclassification/v0/shufflenet_v2/shufflenet_v2_batch1024_imagenet_20200812-5bf4721e.pth
```
<!-- [TABS - END] -->
## Models and results
### Image Classification on ImageNet-1k
| Model | Pretrain | Params (M) | Flops (G) | Top-1 (%) | Top-5 (%) | Config | Download |
| :----------------------------- | :----------: | :--------: | :-------: | :-------: | :-------: | :---------------------------------------: | :------------------------------------------------------------------------------: |
| `shufflenet-v2-1x_16xb64_in1k` | From scratch | 2.28 | 0.15 | 69.55 | 88.92 | [config ](shufflenet-v2-1x_16xb64_in1k.py ) | [model ](https://download.openmmlab.com/mmclassification/v0/shufflenet_v2/shufflenet_v2_batch1024_imagenet_20200812-5bf4721e.pth ) \| [log ](https://download.openmmlab.com/mmclassification/v0/shufflenet_v2/shufflenet_v2_batch1024_imagenet_20200812-5bf4721e.json ) |
## Citation
```bibtex
2020-12-18 20:04:54 +08:00
@inproceedings {ma2018shufflenet,
title={Shufflenet v2: Practical guidelines for efficient cnn architecture design},
author={Ma, Ningning and Zhang, Xiangyu and Zheng, Hai-Tao and Sun, Jian},
booktitle={Proceedings of the European conference on computer vision (ECCV)},
pages={116--131},
year={2018}
}
```