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 9.9 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
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. ├─loss.py # Customized CrossEntropy loss function
  66. └─lr_generator.py # learning rate generator
  67. ├─train.py # train net
  68. ├─export.py # export net
  69. └─eval.py # eval net
  70. ```
  71. ## [Script Parameters](#contents)
  72. ```python
  73. Major parameters in train.py and config.py are:
  74. 'num_classes': 1000 # dataset class numbers
  75. 'batch_size': 128 # input batchsize
  76. 'loss_scale': 1024 # loss scale
  77. 'momentum': 0.9 # momentum
  78. 'weight_decay': 1e-4 # weight decay
  79. 'epoch_size': 250 # total epoch numbers
  80. 'save_checkpoint': True # save checkpoint
  81. 'save_checkpoint_epochs': 1 # save checkpoint epochs
  82. 'keep_checkpoint_max': 5 # max numbers to keep checkpoints
  83. 'save_checkpoint_path': "./" # save checkpoint path
  84. 'warmup_epochs': 1 # warmup epoch numbers
  85. 'lr_decay_mode': "liner" # lr decay mode
  86. 'use_label_smooth': True # use label smooth
  87. 'finish_epoch': 0 # finished epochs numbers
  88. 'label_smooth_factor': 0.1 # label smoothing factor
  89. 'lr_init': 0.00004 # initiate learning rate
  90. 'lr_max': 0.4 # max bound of learning rate
  91. 'lr_end': 0.00004 # min bound of learning rate
  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. ### Launch
  105. ``` shell
  106. # training example
  107. python:
  108. Ascend:
  109. python train.py --device_target Ascend --dataset_path /dataset/train
  110. shell:
  111. Ascend:
  112. # distribute training example(8p)
  113. sh scripts/run_distribute_train.sh RANK_TABLE_FILE DATA_PATH
  114. # standalone training
  115. sh scripts/run_standalone_train.sh DEVICE_ID DATA_PATH
  116. ```
  117. ### Result
  118. Training result will be stored in the example path. Checkpoints will be stored at `. /ckpt_0` by default, and training log will be redirected to `log.txt` like following.
  119. ``` shell
  120. epoch: 1 step: 1251, loss is 4.8427444
  121. epoch time: 701242.350 ms, per step time: 560.545 ms
  122. epoch: 2 step: 1251, loss is 4.0637593
  123. epoch time: 598591.422 ms, per step time: 478.490 ms
  124. ```
  125. ## [Eval process](#contents)
  126. ### Usage
  127. You can start training using python or shell scripts. The usage of shell scripts as follows:
  128. ```shell
  129. sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  130. ```
  131. ### Launch
  132. ```shell
  133. # eval example
  134. python:
  135. Ascend: python eval.py --device_target Ascend --checkpoint_path PATH_CHECKPOINT --dataset_path DATA_DIR
  136. shell:
  137. Ascend: sh scripts/run_eval.sh DEVICE_ID DATA_DIR PATH_CHECKPOINT
  138. ```
  139. > checkpoint can be produced in training process.
  140. ### Result
  141. Evaluation result will be stored in the example path, you can find result like the following in `eval.log`.
  142. ```shell
  143. result: {'Loss': 1.7797744848789312, 'Top_1_Acc': 0.7985777243589743, 'Top_5_Acc': 0.9485777243589744}
  144. ```
  145. # [Model description](#contents)
  146. ## [Performance](#contents)
  147. ### Training Performance
  148. | Parameters | Ascend |
  149. | -------------------------- | ---------------------------------------------- |
  150. | Model Version | Xception |
  151. | Resource | HUAWEI CLOUD Modelarts |
  152. | uploaded Date | 12/10/2020 |
  153. | MindSpore Version | 1.1.0 |
  154. | Dataset | 1200k images |
  155. | Batch_size | 128 |
  156. | Training Parameters | src/config.py |
  157. | Optimizer | Momentum |
  158. | Loss Function | CrossEntropySmooth |
  159. | Loss | 1.78 |
  160. | Accuracy (8p) | Top1[79.8%] Top5[94.8%] |
  161. | Per step time (8p) | 479 ms/step |
  162. | Total time (8p) | 42h |
  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 | 12/10/2020 |
  171. | MindSpore Version | 1.1.0 |
  172. | Dataset | 50k images |
  173. | Batch_size | 128 |
  174. | Accuracy | Top1[79.8%] Top5[94.8%] |
  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).