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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # Contents
  2. - [EfficientNet-B0 Description](#efficientnet-description)
  3. - [Model Architecture](#model-architecture)
  4. - [Dataset](#dataset)
  5. - [Environment Requirements](#environment-requirements)
  6. - [Quick Start](#quick-start)
  7. - [Script Description](#script-description)
  8. - [Script and Sample Code](#script-and-sample-code)
  9. - [Script Parameters](#script-parameters)
  10. - [Training Process](#training-process)
  11. - [Evaluation Process](#evaluation-process)
  12. - [Model Description](#model-description)
  13. - [Performance](#performance)
  14. - [Training Performance](#evaluation-performance)
  15. - [Inference Performance](#evaluation-performance)
  16. - [ModelZoo Homepage](#modelzoo-homepage)
  17. # [EfficientNet-B0 Description](#contents)
  18. [Paper](https://arxiv.org/abs/1905.11946): Mingxing Tan, Quoc V. Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. 2019.
  19. # [Model architecture](#contents)
  20. The overall network architecture of EfficientNet-B0 is show below:
  21. [Link](https://arxiv.org/abs/1905.11946)
  22. # [Dataset](#contents)
  23. Dataset used: [imagenet](http://www.image-net.org/)
  24. - Dataset size: ~125G, 1.2W colorful images in 1000 classes
  25. - Train: 120G, 1.2W images
  26. - Test: 5G, 50000 images
  27. - Data format: RGB images.
  28. - Note: Data will be processed in src/dataset.py
  29. # [Environment Requirements](#contents)
  30. - Hardware GPU
  31. - Prepare hardware environment with GPU processor.
  32. - Framework
  33. - [MindSpore](https://www.mindspore.cn/install/en)
  34. - For more information, please check the resources below:
  35. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  36. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  37. # [Script description](#contents)
  38. ## [Script and sample code](#contents)
  39. ```python
  40. .
  41. └─efficientnet
  42. ├─README.md
  43. ├─scripts
  44. ├─run_standalone_train_for_gpu.sh # launch standalone training with gpu platform(1p)
  45. ├─run_distribute_train_for_gpu.sh # launch distributed training with gpu platform(8p)
  46. └─run_eval_for_gpu.sh # launch evaluating with gpu platform
  47. ├─src
  48. ├─config.py # parameter configuration
  49. ├─dataset.py # data preprocessing
  50. ├─efficientnet.py # network definition
  51. ├─loss.py # Customized loss function
  52. ├─transform_utils.py # random augment utils
  53. ├─transform.py # random augment class
  54. ├─eval.py # eval net
  55. └─train.py # train net
  56. ```
  57. ## [Script Parameters](#contents)
  58. Parameters for both training and evaluating can be set in config.py.
  59. ```
  60. 'random_seed': 1, # fix random seed
  61. 'model': 'efficientnet_b0', # model name
  62. 'drop': 0.2, # dropout rate
  63. 'drop_connect': 0.2, # drop connect rate
  64. 'opt_eps': 0.001, # optimizer epsilon
  65. 'lr': 0.064, # learning rate LR
  66. 'batch_size': 128, # batch size
  67. 'decay_epochs': 2.4, # epoch interval to decay LR
  68. 'warmup_epochs': 5, # epochs to warmup LR
  69. 'decay_rate': 0.97, # LR decay rate
  70. 'weight_decay': 1e-5, # weight decay
  71. 'epochs': 600, # number of epochs to train
  72. 'workers': 8, # number of data processing processes
  73. 'amp_level': 'O0', # amp level
  74. 'opt': 'rmsprop', # optimizer
  75. 'num_classes': 1000, # number of classes
  76. 'gp': 'avg', # type of global pool, "avg", "max", "avgmax", "avgmaxc"
  77. 'momentum': 0.9, # optimizer momentum
  78. 'warmup_lr_init': 0.0001, # init warmup LR
  79. 'smoothing': 0.1, # label smoothing factor
  80. 'bn_tf': False, # use Tensorflow BatchNorm defaults
  81. 'keep_checkpoint_max': 10, # max number ckpts to keep
  82. 'loss_scale': 1024, # loss scale
  83. 'resume_start_epoch': 0, # resume start epoch
  84. ```
  85. ## [Training Process](#contents)
  86. #### Usage
  87. ```
  88. GPU:
  89. # distribute training example(8p)
  90. sh run_distribute_train_for_gpu.sh
  91. # standalone training
  92. sh run_standalone_train_for_gpu.sh DEVICE_ID DATA_DIR
  93. ```
  94. #### Launch
  95. ```bash
  96. # distributed training example(8p) for GPU
  97. cd scripts
  98. sh run_distribute_train_for_gpu.sh 8 0,1,2,3,4,5,6,7 /dataset/train
  99. # standalone training example for GPU
  100. cd scripts
  101. sh run_standalone_train_for_gpu.sh 0 /dataset/train
  102. ```
  103. You can find checkpoint file together with result in log.
  104. ## [Evaluation Process](#contents)
  105. ### Usage
  106. ```
  107. # Evaluation
  108. sh run_eval_for_gpu.sh DATA_DIR DEVICE_ID PATH_CHECKPOINT
  109. ```
  110. #### Launch
  111. ```bash
  112. # Evaluation with checkpoint
  113. cd scripts
  114. sh run_eval_for_gpu.sh /dataset/eval ./checkpoint/efficientnet_b0-600_1251.ckpt
  115. ```
  116. #### Result
  117. Evaluation result will be stored in the scripts path. Under this, you can find result like the followings in log.
  118. ```
  119. acc=76.96%(TOP1)
  120. ```
  121. # [Model description](#contents)
  122. ## [Performance](#contents)
  123. ### Training Performance
  124. | Parameters | efficientnet_b0 |
  125. | -------------------------- | ------------------------- |
  126. | Resource | NV SMX2 V100-32G |
  127. | uploaded Date | 10/26/2020 |
  128. | MindSpore Version | 1.0.0 |
  129. | Dataset | ImageNet |
  130. | Training Parameters | src/config.py |
  131. | Optimizer | rmsprop |
  132. | Loss Function | LabelSmoothingCrossEntropy |
  133. | Loss | 1.8886 |
  134. | Accuracy | 76.96%(TOP1) |
  135. | Total time | 132 h 8ps |
  136. | Checkpoint for Fine tuning | 64 M(.ckpt file) |
  137. ### Inference Performance
  138. | Parameters | |
  139. | -------------------------- | ------------------------- |
  140. | Resource | NV SMX2 V100-32G |
  141. | uploaded Date | 10/26/2020 |
  142. | MindSpore Version | 1.0.0 |
  143. | Dataset | ImageNet, 1.2W |
  144. | batch_size | 128 |
  145. | outputs | probability |
  146. | Accuracy | acc=76.96%(TOP1) |
  147. # [ModelZoo Homepage](#contents)
  148. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).