You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Readme.md 8.7 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. # Contents
  2. - [MobileNetV2 Description](#mobilenetv2-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Features](#features)
  6. - [Mixed Precision](#mixed-precision)
  7. - [Environment Requirements](#environment-requirements)
  8. - [Script Description](#script-description)
  9. - [Script and Sample Code](#script-and-sample-code)
  10. - [Training Process](#training-process)
  11. - [Evaluation Process](#evaluation-process)
  12. - [Model Description](#model-description)
  13. - [Performance](#performance)
  14. - [Training Performance](#training-performance)
  15. - [Evaluation Performance](#evaluation-performance)
  16. - [Description of Random Situation](#description-of-random-situation)
  17. - [ModelZoo Homepage](#modelzoo-homepage)
  18. # [MobileNetV2 Description](#contents)
  19. MobileNetV2 is tuned to mobile phone CPUs through a combination of hardware- aware network architecture search (NAS) complemented by the NetAdapt algorithm and then subsequently improved through novel architecture advances.Nov 20, 2019.
  20. [Paper](https://arxiv.org/pdf/1905.02244) Howard, Andrew, Mark Sandler, Grace Chu, Liang-Chieh Chen, Bo Chen, Mingxing Tan, Weijun Wang et al. "Searching for MobileNetV2." In Proceedings of the IEEE International Conference on Computer Vision, pp. 1314-1324. 2019.
  21. This is the quantitative network of MobileNetV2.
  22. # [Model architecture](#contents)
  23. The overall network architecture of MobileNetV2 is show below:
  24. [Link](https://arxiv.org/pdf/1905.02244)
  25. # [Dataset](#contents)
  26. Dataset used: [imagenet](http://www.image-net.org/)
  27. - Dataset size: ~125G, 1.2W colorful images in 1000 classes
  28. - Train: 120G, 1.2W images
  29. - Test: 5G, 50000 images
  30. - Data format: RGB images.
  31. - Note: Data will be processed in src/dataset.py
  32. # [Features](#contents)
  33. ## [Mixed Precision](#contents)
  34. The [mixed precision](https://www.mindspore.cn/tutorial/zh-CN/master/advanced_use/mixed_precision.html) training method accelerates the deep learning neural network training process by using both the single-precision and half-precision data formats, and maintains the network precision achieved by the single-precision training at the same time. Mixed precision training can accelerate the computation process, reduce memory usage, and enable a larger model or batch size to be trained on specific hardware.
  35. For FP16 operators, if the input data type is FP32, the backend of MindSpore will automatically handle it with reduced precision. Users could check the reduced-precision operators by enabling INFO log and then searching ‘reduce precision’.
  36. # [Environment Requirements](#contents)
  37. - Hardware:Ascend
  38. - Prepare hardware environment with Ascend. If you want to try Ascend , please send the [application form](https://obs-9be7.obs.cn-east-2.myhuaweicloud.com/file/other/Ascend%20Model%20Zoo%E4%BD%93%E9%AA%8C%E8%B5%84%E6%BA%90%E7%94%B3%E8%AF%B7%E8%A1%A8.docx) to ascend@huawei.com. Once approved, you can get the resources.
  39. - Framework
  40. - [MindSpore](https://www.mindspore.cn/install/en)
  41. - For more information, please check the resources below
  42. - [MindSpore tutorials](https://www.mindspore.cn/tutorial/zh-CN/master/index.html)
  43. - [MindSpore API](https://www.mindspore.cn/api/zh-CN/master/index.html)
  44. # [Script description](#contents)
  45. ## [Script and sample code](#contents)
  46. ```python
  47. ├── mobileNetv2_quant
  48. ├── Readme.md # descriptions about MobileNetV2-Quant
  49. ├── scripts
  50. │ ├──run_train.sh # shell script for train on Ascend
  51. │ ├──run_infer.sh # shell script for evaluation on Ascend
  52. ├── src
  53. │ ├──config.py # parameter configuration
  54. │ ├──dataset.py # creating dataset
  55. │ ├──launch.py # start python script
  56. │ ├──lr_generator.py # learning rate config
  57. │ ├──mobilenetV2.py # MobileNetV2 architecture
  58. │ ├──utils.py # supply the monitor module
  59. ├── train.py # training script
  60. ├── eval.py # evaluation script
  61. ├── export.py # export checkpoint files into air/onnx
  62. ```
  63. ## [Training process](#contents)
  64. ### Usage
  65. You can start training using python or shell scripts. The usage of shell scripts as follows:
  66. - bash run_train.sh [Ascend] [RANK_TABLE_FILE] [DATASET_PATH] [PRETRAINED_CKPT_PATH]\(optional)
  67. - bash run_train.sh [GPU] [DEVICE_ID_LIST] [DATASET_PATH] [PRETRAINED_CKPT_PATH]\(optional)
  68. ### Launch
  69. ``` bash
  70. # training example
  71. >>> bash run_train.sh Ascend ~/hccl_4p_0123_x.x.x.x.json ~/imagenet/train/ ~/mobilenet.ckpt
  72. >>> bash run_train.sh GPU 1,2 ~/imagenet/train/ ~/mobilenet.ckpt
  73. ```
  74. ### Result
  75. Training result will be stored in the example path. Checkpoints trained by `Ascend` will be stored at `./train/device$i/checkpoint` by default, and training log will be redirected to `./train/device$i/train.log`. Checkpoints trained by `GPU` will be stored in `./train/checkpointckpt_$i` by default, and training log will be redirected to `./train/train.log`.
  76. `train.log` is as follows:
  77. ```
  78. epoch: [ 0/200], step:[ 624/ 625], loss:[5.258/5.258], time:[140412.236], lr:[0.100]
  79. epoch time: 140522.500, per step time: 224.836, avg loss: 5.258
  80. epoch: [ 1/200], step:[ 624/ 625], loss:[3.917/3.917], time:[138221.250], lr:[0.200]
  81. epoch time: 138331.250, per step time: 221.330, avg loss: 3.917
  82. ```
  83. ## [Evaluation process](#contents)
  84. ### Usage
  85. You can start training using python or shell scripts. The usage of shell scripts as follows:
  86. - Ascend: sh run_infer_quant.sh Ascend [DATASET_PATH] [CHECKPOINT_PATH]
  87. ### Launch
  88. ```
  89. # infer example
  90. shell:
  91. Ascend: sh run_infer_quant.sh Ascend ~/imagenet/val/ ~/train/mobilenet-60_1601.ckpt
  92. ```
  93. > checkpoint can be produced in training process.
  94. ### Result
  95. Inference result will be stored in the example path, you can find result like the followings in `./val/infer.log`.
  96. ```
  97. result: {'acc': 0.71976314102564111}
  98. ```
  99. # [Model description](#contents)
  100. ## [Performance](#contents)
  101. ### Training Performance
  102. | Parameters | MobilenetV2 |
  103. | -------------------------- | ---------------------------------------------------------- |
  104. | Model Version | V2 |
  105. | Resource | Ascend 910, cpu:2.60GHz 56cores, memory:314G |
  106. | uploaded Date | 06/06/2020 |
  107. | MindSpore Version | 0.3.0 |
  108. | Dataset | ImageNet |
  109. | Training Parameters | src/config.py |
  110. | Optimizer | Momentum |
  111. | Loss Function | SoftmaxCrossEntropy |
  112. | outputs | ckpt file |
  113. | Loss | 1.913 |
  114. | Accuracy | |
  115. | Total time | 16h |
  116. | Params (M) | batch_size=192, epoch=60 |
  117. | Checkpoint for Fine tuning | |
  118. | Model for inference | |
  119. #### Evaluation Performance
  120. | Parameters | |
  121. | -------------------------- | ----------------------------- |
  122. | Model Version | V2 |
  123. | Resource | Ascend 910 |
  124. | uploaded Date | 06/06/2020 |
  125. | MindSpore Version | 0.3.0 |
  126. | Dataset | ImageNet, 1.2W |
  127. | batch_size | 130(8P) |
  128. | outputs | probability |
  129. | Accuracy | ACC1[71.78%] ACC5[90.90%] |
  130. | Speed | 200ms/step |
  131. | Total time | 5min |
  132. | Model for inference | |
  133. # [Description of Random Situation](#contents)
  134. In dataset.py, we set the seed inside “create_dataset" function. We also use random seed in train.py.
  135. # [ModelZoo Homepage](#contents)
  136. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).