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 10 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. # Contents
  2. - [Contents](#contents)
  3. - [Xception Description](#xception-description)
  4. - [Model architecture](#model-architecture)
  5. - [Dataset](#dataset)
  6. - [Features](#features)
  7. - [Mixed Precision(Ascend)](#mixed-precisionascend)
  8. - [Environment Requirements](#environment-requirements)
  9. - [Script description](#script-description)
  10. - [Script and sample code](#script-and-sample-code)
  11. - [Script Parameters](#script-parameters)
  12. - [Training process](#training-process)
  13. - [Usage](#usage)
  14. - [Launch](#launch)
  15. - [Result](#result)
  16. - [Eval process](#eval-process)
  17. - [Usage](#usage-1)
  18. - [Launch](#launch-1)
  19. - [Result](#result-1)
  20. - [Model description](#model-description)
  21. - [Performance](#performance)
  22. - [Training Performance](#training-performance)
  23. - [Inference Performance](#inference-performance)
  24. - [Description of Random Situation](#description-of-random-situation)
  25. - [ModelZoo Homepage](#modelzoo-homepage)
  26. # [Xception Description](#contents)
  27. Xception by Google is extreme version of Inception. With a modified depthwise separable convolution, it is even better than Inception-v3. This paper was published in 2017.
  28. [Paper](https://arxiv.org/pdf/1610.02357v3.pdf) Franois Chollet. Xception: Deep Learning with Depthwise Separable Convolutions. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR) IEEE, 2017.
  29. # [Model architecture](#contents)
  30. The overall network architecture of Xception is show below:
  31. [Link](https://arxiv.org/pdf/1610.02357v3.pdf)
  32. # [Dataset](#contents)
  33. Dataset used can refer to paper.
  34. - Dataset size: 125G, 1250k colorful images in 1000 classes
  35. - Train: 120G, 1200k images
  36. - Test: 5G, 50k images
  37. - Data format: RGB images.
  38. - Note: Data will be processed in src/dataset.py
  39. # [Features](#contents)
  40. ## [Mixed Precision(Ascend)](#contents)
  41. The [mixed precision](https://www.mindspore.cn/tutorial/training/en/master/advanced_use/enable_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.
  42. 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’.
  43. # [Environment Requirements](#contents)
  44. - Hardware(Ascend)
  45. - 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.
  46. - Framework
  47. - [MindSpore](https://www.mindspore.cn/install/en)
  48. - For more information, please check the resources below:
  49. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  50. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  51. # [Script description](#contents)
  52. ## [Script and sample code](#contents)
  53. ```shell
  54. .
  55. └─Xception
  56. ├─README.md
  57. ├─scripts
  58. ├─run_standalone_train.sh # launch standalone training with ascend platform(1p)
  59. ├─run_distribute_train.sh # launch distributed training with ascend platform(8p)
  60. └─run_eval.sh # launch evaluating with ascend platform
  61. ├─src
  62. ├─config.py # parameter configuration
  63. ├─dataset.py # data preprocessing
  64. ├─Xception.py # network definition
  65. ├─CrossEntropySmooth.py # Customized CrossEntropy loss function
  66. └─lr_generator.py # learning rate generator
  67. ├─train.py # train net
  68. └─eval.py # eval net
  69. ```
  70. ## [Script Parameters](#contents)
  71. ```python
  72. Major parameters in train.py and config.py are:
  73. 'num_classes': 1000 # dataset class numbers
  74. 'batch_size': 128 # input batchsize
  75. 'loss_scale': 1024 # loss scale
  76. 'momentum': 0.9 # momentum
  77. 'weight_decay': 1e-4 # weight decay
  78. 'epoch_size': 250 # total epoch numbers
  79. 'save_checkpoint': True # save checkpoint
  80. 'save_checkpoint_epochs': 1 # save checkpoint epochs
  81. 'keep_checkpoint_max': 5 # max numbers to keep checkpoints
  82. 'save_checkpoint_path': "./" # save checkpoint path
  83. 'warmup_epochs': 1 # warmup epoch numbers
  84. 'lr_decay_mode': "liner" # lr decay mode
  85. 'use_label_smooth': True # use label smooth
  86. 'finish_epoch': 0 # finished epochs numbers
  87. 'label_smooth_factor': 0.1 # label smoothing factor
  88. 'lr_init': 0.00004 # initiate learning rate
  89. 'lr_max': 0.4 # max bound of learning rate
  90. 'lr_end': 0.00004 # min bound of learning rate
  91. "weight_init": 'xavier_uniform' # Weight initialization mode
  92. ```
  93. ## [Training process](#contents)
  94. ### Usage
  95. You can start training using python or shell scripts. The usage of shell scripts as follows:
  96. - Ascend:
  97. ```shell
  98. # distribute training example(8p)
  99. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  100. # standalone training
  101. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  102. ```
  103. > Notes: RANK_TABLE_FILE can refer to [Link](https://www.mindspore.cn/tutorial/training/en/master/advanced_use/distributed_training_ascend.html), and the device_ip can be got as [Link](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/utils/hccl_tools).
  104. > This is processor cores binding operation regarding the `device_num` and total processor numbers. If you are not expect to do it, remove the operations `taskset` in `scripts/run_distribute_train.sh`
  105. ### Launch
  106. ``` shell
  107. # training example
  108. python:
  109. Ascend:
  110. python train.py --device_target Ascend --dataset_path /dataset/train
  111. shell:
  112. Ascend:
  113. # distribute training example(8p)
  114. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  115. # standalone training
  116. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  117. ```
  118. ### Result
  119. Training result will be stored in the example path. Checkpoints will be stored at `. /model_0` by default, and training log will be redirected to `log.txt` like followings.
  120. ``` shell
  121. epoch: [ 0/250], step:[ 1250/ 1251], loss:[4.761/5.613], time:[529.305], lr:[0.400]
  122. epoch time: 1128662.862, per step time: 902.209, avg loss: 5.609
  123. epoch: [ 1/250], step:[ 1250/ 1251], loss:[4.164/4.318], time:[503.708], lr:[0.398]
  124. epoch time: 889163.081, per step time: 710.762, avg loss: 4.312
  125. ```
  126. ## [Eval process](#contents)
  127. ### Usage
  128. You can start training using python or shell scripts. The usage of shell scripts as follows:
  129. ```shell
  130. sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  131. ```
  132. ### Launch
  133. ```shell
  134. # eval example
  135. python:
  136. Ascend: python eval.py --device_target Ascend --checkpoint_path PATH_CHECKPOINT --dataset_path DATA_DIR
  137. shell:
  138. Ascend: sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  139. ```
  140. > checkpoint can be produced in training process.
  141. ### Result
  142. Evaluation result will be stored in the example path, you can find result like the followings in `eval.log`.
  143. ```shell
  144. result: {'Loss': 1.7797744848789312, 'Top_1_Acc': 0.7985777243589743, 'Top_5_Acc': 0.9485777243589744}
  145. ```
  146. # [Model description](#contents)
  147. ## [Performance](#contents)
  148. ### Training Performance
  149. | Parameters | Ascend |
  150. | -------------------------- | ---------------------------------------------- |
  151. | Model Version | Xception |
  152. | Resource | HUAWEI CLOUD Modelarts |
  153. | uploaded Date | 11/15/2020 |
  154. | MindSpore Version | 1.0.0 |
  155. | Dataset | 1200k images |
  156. | Batch_size | 128 |
  157. | Training Parameters | src/config.py |
  158. | Optimizer | Momentum |
  159. | Loss Function | CrossEntropySmooth |
  160. | Loss | 1.78 |
  161. | Accuracy (8p) | Top1[79.9%] Top5[94.9%] |
  162. | Total time (8p) | 63h |
  163. | Params (M) | 180M |
  164. | Scripts | [Xception script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/Xception) |
  165. #### Inference Performance
  166. | Parameters | Ascend |
  167. | ------------------- | --------------------------- |
  168. | Model Version | Xception |
  169. | Resource | HUAWEI CLOUD Modelarts |
  170. | Uploaded Date | 11/15/2020 |
  171. | MindSpore Version | 1.0.0 |
  172. | Dataset | 50k images |
  173. | Batch_size | 128 |
  174. | Accuracy | Top1[79.9%] Top5[94.9%] |
  175. | Total time | 3mins |
  176. # [Description of Random Situation](#contents)
  177. In `dataset.py`, we set the seed inside `create_dataset` function. We also use random seed in `train.py`.
  178. # [ModelZoo Homepage](#contents)
  179. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).