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

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. # Contents
  2. - [FCN Description](#fcn-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. - [Data Generation](#data-generation)
  11. - [Training Data](#training-data)
  12. - [Training Process](#training-process)
  13. - [Training](#training)
  14. - [Evaluation Process](#evaluation-process)
  15. - [Evaluation](#evaluation)
  16. - [Model Description](#model-description)
  17. - [Performance](#performance)
  18. - [Evaluation Performance](#evaluation-performance)
  19. - [Inference Performance](#inference-performance)
  20. - [Description of Random Situation](#description-of-random-situation)
  21. - [ModelZoo Homepage](#modelzoo-homepage)
  22. # [FCN Description](#contents)
  23. FCN is mainly used in the field of image segmentation, which is an end-to-end segmentation method. FCN changes the last full connected layers of VGG to process images of any size, reduce the parameters and improve the segmentation speed of the model. FCN uses VGG structure in the encoding part and deconvolution / up sampling operation in the decoding part to recover the image resolution. Finally, FCN8s uses 8 times deconvolution / up sampling operation to restore the output image to the same size as the input image.
  24. [Paper]: Long, Jonathan, Evan Shelhamer, and Trevor Darrell. "Fully convolutional networks for semantic segmentation." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2015.
  25. # [Model Architecture](#contents)
  26. FCN8s uses VGG16 without the full connected layers as the encoding part, and fuses the features of the 3rd, 4th and 5th pooling layers in VGG16 respectively. Finally, the deconvolution of stride 8 is used to obtain the segmented image.
  27. # [Dataset](#contents)
  28. Dataset used:
  29. [PASCAL VOC 2012](<http://host.robots.ox.ac.uk/pascal/VOC/voc2012/index.html>)
  30. # [Environment Requirements](#contents)
  31. - Hardware(Ascend)
  32. - Prepare hardware environment with Ascend processor.
  33. - Architecture
  34. - [MindSpore](https://www.mindspore.cn/install/en)
  35. - For more information, please check the resources below:
  36. - [MindSpore Tutorials](https://www.mindspore.cn/tutorial/training/en/master/index.html)
  37. - [MindSpore Python API](https://www.mindspore.cn/doc/api_python/en/master/index.html)
  38. # [Quick Start](#contents)
  39. After installing MindSpore through the official website, you can start training and evaluation by following these steps:
  40. - running on Ascend with default parameters
  41. ```bash
  42. # run training example
  43. python train.py --device_id device_id
  44. # run evaluation example with default parameters
  45. python eval.py --device_id device_id
  46. ```
  47. # [Script Description](#contents)
  48. ## [Script and Sample Code](#contents)
  49. ```bash
  50. ├── cv
  51. ├── FCN8s
  52. ├── README.md // descriptions about FCN
  53. ├── scripts
  54. ├── run_train.sh
  55. ├── run_standalone_train.sh
  56. ├── run_eval.sh
  57. ├── build_data.sh
  58. ├── src
  59. │ ├──data
  60. │ ├──build_seg_data.py // creating dataset
  61. │ ├──dataset.py // loading dataset
  62. │ ├──nets
  63. │ ├──FCN8s.py // FCN-8s architecture
  64. │ ├──loss
  65. │ ├──loss.py // loss function
  66. │ ├──utils
  67. │ ├──lr_scheduler.py // getting learning_rateFCN-8s
  68. ├── train.py // training script
  69. ├── eval.py // evaluation script
  70. ```
  71. ## [Script Parameters](#contents)
  72. Parameters for both training and evaluation can be set in config.py.
  73. - config for FCN8s
  74. ```python
  75. # dataset
  76. 'data_file': '/data/workspace/mindspore_dataset/FCN/FCN/dataset/MINDRECORED_NAME.mindrecord', # path and name of one mindrecord file
  77. 'batch_size': 32,
  78. 'crop_size': 512,
  79. 'image_mean': [103.53, 116.28, 123.675],
  80. 'image_std': [57.375, 57.120, 58.395],
  81. 'min_scale': 0.5,
  82. 'max_scale': 2.0,
  83. 'ignore_label': 255,
  84. 'num_classes': 21,
  85. # optimizer
  86. 'train_epochs': 500,
  87. 'base_lr': 0.015,
  88. 'loss_scale': 1024.0,
  89. # model
  90. 'model': 'FCN8s',
  91. 'ckpt_vgg16': '',
  92. 'ckpt_pre_trained': '',
  93. # train
  94. 'save_steps': 330,
  95. 'keep_checkpoint_max': 5,
  96. 'ckpt_dir': './ckpt',
  97. ```
  98. For more information, see `config.py`.
  99. ## [Data Generation](#contents)
  100. ### Training Data
  101. - build mindrecord training data
  102. ```bash
  103. sh build_data.sh
  104. or
  105. python src/data/build_seg_data.py --data_root=/home/sun/data/Mindspore/benchmark_RELEASE/dataset \
  106. --data_lst=/home/sun/data/Mindspore/benchmark_RELEASE/dataset/trainaug.txt \
  107. --dst_path=dataset/MINDRECORED_NAME.mindrecord \
  108. --num_shards=1 \
  109. --shuffle=True
  110. ```
  111. ## [Training Process](#contents)
  112. ### Training
  113. - running on Ascend with default parameters
  114. ```bash
  115. python train.py --device_id device_id
  116. ```
  117. Checkpoints will be stored in the default path
  118. ## [Evaluation Process](#contents)
  119. ### Evaluation
  120. - Evaluated on Pascal VOC 2012 validation set using Ascend
  121. Before running the command, check the path of the checkpoint used for evaluation. Please set the absolute path of the checkpoint
  122. ```bash
  123. python eval.py
  124. ```
  125. After running the above command, you can see the evaluation results on the terminal. The accuracy on the test set is presented as follows:
  126. ```bash
  127. mean IoU 0.6425
  128. ```
  129. # [Model Description](#contents)
  130. ## [Performance](#contents)
  131. ### Evaluation Performance
  132. | Parameters | Ascend
  133. | -------------------------- | -----------------------------------------------------------
  134. | Model Version | FCN-8s
  135. | Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory 755G; OS Euler2.8
  136. | uploaded Date | 12/30/2020 (month/day/year)
  137. | MindSpore Version | 1.1.0-alpha
  138. | Dataset | PASCAL VOC 2012
  139. | Training Parameters | epoch=500, steps=330, batch_size = 32, lr=0.015
  140. | Optimizer | Momentum
  141. | Loss Function | Softmax Cross Entropy
  142. | outputs | probability
  143. | Loss | 0.038
  144. | Speed | 1pc: 564.652 ms/step;
  145. | Scripts | [FCN script](https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/cv/FCN8s)
  146. ### Inference Performance
  147. #### FCN8s on PASCAL VOC
  148. | Parameters | Ascend
  149. | ------------------- | ---------------------------
  150. | Model Version | FCN-8s
  151. | Resource | Ascend 910; OS Euler2.8
  152. | Uploaded Date | 12/30/2020 (month/day/year)
  153. | MindSpore Version | 1.1.0-alpha
  154. | Dataset | PASCAL VOC 2012
  155. | batch_size | 16
  156. | outputs | probability
  157. | mean IoU | 64.25
  158. # [Description of Random Situation](#contents)
  159. We set the random seeds in train.py.
  160. # [ModelZoo Homepage](#contents)
  161. Please check the official [homepage](https://gitee.com/mindspore/mindspore/tree/master/model_zoo).