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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # YOLOV3-DarkNet53 Example
  2. ## Description
  3. This is an example of training YOLOV3-DarkNet53 with COCO2014 dataset in MindSpore.
  4. ## Requirements
  5. - Install [MindSpore](https://www.mindspore.cn/install/en).
  6. - Download the dataset COCO2014.
  7. > Unzip the COCO2014 dataset to any path you want, the folder should include train and eval dataset as follows:
  8. ```
  9. .
  10. └─dataset
  11. ├─train2014
  12. ├─val2014
  13. └─annotations
  14. ```
  15. ## Structure
  16. ```shell
  17. .
  18. └─yolov3_darknet53
  19. ├─README.md
  20. ├─scripts
  21. ├─run_standalone_train.sh # launch standalone training(1p)
  22. ├─run_distribute_train.sh # launch distributed training(8p)
  23. └─run_eval.sh # launch evaluating
  24. ├─src
  25. ├─__init__.py # python init file
  26. ├─config.py # parameter configuration
  27. ├─darknet.py # backbone of network
  28. ├─distributed_sampler.py # iterator of dataset
  29. ├─initializer.py # initializer of parameters
  30. ├─logger.py # log function
  31. ├─loss.py # loss function
  32. ├─lr_scheduler.py # generate learning rate
  33. ├─transforms.py # Preprocess data
  34. ├─util.py # util function
  35. ├─yolo.py # yolov3 network
  36. ├─yolo_dataset.py # create dataset for YOLOV3
  37. ├─eval.py # eval net
  38. └─train.py # train net
  39. ```
  40. ## Running the example
  41. ### Train
  42. #### Usage
  43. ```
  44. # distributed training
  45. sh run_distribute_train.sh [DATASET_PATH] [PRETRAINED_BACKBONE] [RANK_TABLE_FILE]
  46. # standalone training
  47. sh run_standalone_train.sh [DATASET_PATH] [PRETRAINED_BACKBONE]
  48. ```
  49. #### Launch
  50. ```bash
  51. # distributed training example(8p)
  52. sh run_distribute_train.sh dataset/coco2014 backbone/backbone.ckpt rank_table_8p.json
  53. # standalone training example(1p)
  54. sh run_standalone_train.sh dataset/coco2014 backbone/backbone.ckpt
  55. ```
  56. > About rank_table.json, you can refer to the [distributed training tutorial](https://www.mindspore.cn/tutorial/en/master/advanced_use/distributed_training.html).
  57. #### Result
  58. Training result will be stored in the scripts path, whose folder name begins with "train" or "train_parallel". You can find checkpoint file together with result like the followings in log.txt.
  59. ```
  60. # distribute training result(8p)
  61. epoch[0], iter[0], loss:14623.384766, 1.23 imgs/sec, lr:7.812499825377017e-05
  62. epoch[0], iter[100], loss:1486.253051, 15.01 imgs/sec, lr:0.007890624925494194
  63. epoch[0], iter[200], loss:288.579535, 490.41 imgs/sec, lr:0.015703124925494194
  64. epoch[0], iter[300], loss:153.136754, 531.99 imgs/sec, lr:0.023515624925494194
  65. epoch[1], iter[400], loss:106.429322, 405.14 imgs/sec, lr:0.03132812678813934
  66. ...
  67. epoch[318], iter[102000], loss:34.135306, 431.06 imgs/sec, lr:9.63797629083274e-06
  68. epoch[319], iter[102100], loss:35.652469, 449.52 imgs/sec, lr:2.409552052995423e-06
  69. epoch[319], iter[102200], loss:34.652273, 384.02 imgs/sec, lr:2.409552052995423e-06
  70. epoch[319], iter[102300], loss:35.430038, 423.49 imgs/sec, lr:2.409552052995423e-06
  71. ...
  72. ```
  73. ### Infer
  74. #### Usage
  75. ```
  76. # infer
  77. sh run_eval.sh [DATASET_PATH] [CHECKPOINT_PATH]
  78. ```
  79. #### Launch
  80. ```bash
  81. # infer with checkpoint
  82. sh run_eval.sh dataset/coco2014/ checkpoint/0-319_102400.ckpt
  83. ```
  84. > checkpoint can be produced in training process.
  85. #### Result
  86. Inference result will be stored in the scripts path, whose folder name is "eval". Under this, you can find result like the followings in log.txt.
  87. ```
  88. =============coco eval reulst=========
  89. Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.311
  90. Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.528
  91. Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.322
  92. Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.127
  93. Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.323
  94. Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.428
  95. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.259
  96. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.398
  97. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.423
  98. Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.224
  99. Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.442
  100. Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.551
  101. ```