You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mindspore/model_zoo/official/cv/shufflenetv2
panfengfeng 121943bdb5
update shufflenetv2 scripts
5 years ago
..
scripts update shufflenetv2 scripts 5 years ago
src update shufflenetv2 scripts 5 years ago
Readme.md update shufflenetv2 scripts 5 years ago
blocks.py Adding ShuffleNetV2 to ModelZoo 5 years ago
eval.py update shufflenetv2 scripts 5 years ago
network.py Adding ShuffleNetV2 to ModelZoo 5 years ago
train.py update shufflenetv2 scripts 5 years ago

Readme.md

Contents

ShuffleNetV2 Description

ShuffleNetV2 is a much faster and more accurate netowrk than the previous networks on different platforms such as Ascend or GPU. Paper Ma, N., Zhang, X., Zheng, H. T., & Sun, J. (2018). Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European conference on computer vision (ECCV) (pp. 116-131).

Model architecture

The overall network architecture of ShuffleNetV2 is show below:

Link

Dataset

Dataset used: imagenet

  • Dataset size: ~125G, 1.2W colorful images in 1000 classes
    • Train: 120G, 1.2W images
    • Test: 5G, 50000 images
  • Data format: RGB images.
    • Note: Data will be processed in src/dataset.py

Environment Requirements

Script description

Script and sample code

+-- ShuffleNetV2      
  +-- Readme.md     # descriptions about ShuffleNetV2
  +-- scripts
  <EFBFBD>   +--run_distribute_train_for_gpu.sh   # shell script for distributed training
  <EFBFBD>   +--run_eval_for_gpu.sh         # shell script for evaluation
  <EFBFBD>   +--run_standalone_train_for_gpu.sh   # shell script for standalone training
  +-- src
  <EFBFBD>   +--config.py      # parameter configuration
  <EFBFBD>   +--dataset.py     # creating dataset
  <EFBFBD>   +--loss.py        # loss function for network
  <EFBFBD>   +--lr_generator.py     # learning rate config
  +-- train.py      # training script
  +-- eval.py       # evaluation script
  +-- blocks.py     # ShuffleNetV2 blocks
  +-- network.py    # ShuffleNetV2 model network

Training process

Usage

You can start training using python or shell scripts. The usage of shell scripts as follows:

  • Ditributed training on GPU: sh run_standalone_train_for_gpu.sh [DEVICE_NUM] [VISIABLE_DEVICES(0,1,2,3,4,5,6,7)] [DATASET_PATH]
  • Standalone training on GPU: sh run_standalone_train_for_gpu.sh [DATASET_PATH]

Launch

# training example
  python:
      GPU: mpirun --allow-run-as-root -n 8 python train.py --is_distributed=True --platform='GPU' --dataset_path='~/imagenet/train/' > train.log 2>&1 &

  shell:
      GPU: cd scripts & sh run_distribute_train_for_gpu.sh 8 0,1,2,3,4,5,6,7 ~/imagenet/train/

Result

Training result will be stored in the example path. Checkpoints will be stored at ./checkpoint by default, and training log will be redirected to ./train/train.log.

Eval process

Usage

You can start evaluation using python or shell scripts. The usage of shell scripts as follows:

  • GPU: sh run_eval_for_gpu.sh [DATASET_PATH] [CHECKPOINT_PATH]

Launch

# infer example
  python:
      GPU: CUDA_VISIBLE_DEVICES=0 python eval.py --platform='GPU' --dataset_path='~/imagenet/val/' > eval.log 2>&1 &

  shell:
      GPU: cd scripts & sh run_eval_for_gpu.sh '~/imagenet/val/' 'checkpoint_file' 

checkpoint can be produced in training process.

Result

Inference result will be stored in the example path, you can find result in eval.log.