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.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. ├─config.py # parameter configuration
  26. ├─darknet.py # backbone of network
  27. ├─distributed_sampler.py # iterator of dataset
  28. ├─initializer.py # initializer of parameters
  29. ├─logger.py # log function
  30. ├─loss.py # loss function
  31. ├─lr_scheduler.py # generate learning rate
  32. ├─transforms.py # Preprocess data
  33. ├─util.py # util function
  34. ├─yolo.py # yolov3 network
  35. ├─yolo_dataset.py # create dataset for YOLOV3
  36. ├─eval.py # eval net
  37. └─train.py # train net
  38. ```
  39. ## Running the example
  40. ### Train
  41. #### Usage
  42. ```
  43. # distributed training
  44. sh run_distribute_train.sh [DATASET_PATH] [PRETRAINED_BACKBONE] [MINDSPORE_HCCL_CONFIG_PATH]
  45. # standalone training
  46. sh run_standalone_train.sh [DATASET_PATH] [PRETRAINED_BACKBONE]
  47. ```
  48. #### Launch
  49. ```bash
  50. # distributed training example(8p)
  51. sh run_distribute_train.sh dataset/coco2014 backbone/backbone.ckpt rank_table_8p.json
  52. # standalone training example(1p)
  53. sh run_standalone_train.sh dataset/coco2014 backbone/backbone.ckpt
  54. ```
  55. > About rank_table.json, you can refer to the [distributed training tutorial](https://www.mindspore.cn/tutorial/en/master/advanced_use/distributed_training.html).
  56. #### Result
  57. 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.
  58. ```
  59. # distribute training result(8p)
  60. epoch[0], iter[0], loss:14623.384766, 1.23 imgs/sec, lr:7.812499825377017e-05
  61. epoch[0], iter[100], loss:1486.253051, 15.01 imgs/sec, lr:0.007890624925494194
  62. epoch[0], iter[200], loss:288.579535, 490.41 imgs/sec, lr:0.015703124925494194
  63. epoch[0], iter[300], loss:153.136754, 531.99 imgs/sec, lr:0.023515624925494194
  64. epoch[1], iter[400], loss:106.429322, 405.14 imgs/sec, lr:0.03132812678813934
  65. ...
  66. epoch[318], iter[102000], loss:34.135306, 431.06 imgs/sec, lr:9.63797629083274e-06
  67. epoch[319], iter[102100], loss:35.652469, 449.52 imgs/sec, lr:2.409552052995423e-06
  68. epoch[319], iter[102200], loss:34.652273, 384.02 imgs/sec, lr:2.409552052995423e-06
  69. epoch[319], iter[102300], loss:35.430038, 423.49 imgs/sec, lr:2.409552052995423e-06
  70. ...
  71. ```
  72. ### Infer
  73. #### Usage
  74. ```
  75. # infer
  76. sh run_eval.sh [DATASET_PATH] [CHECKPOINT_PATH]
  77. ```
  78. #### Launch
  79. ```bash
  80. # infer with checkpoint
  81. sh run_eval.sh dataset/coco2014/ checkpoint/0-319_102400.ckpt
  82. ```
  83. > checkpoint can be produced in training process.
  84. #### Result
  85. 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.
  86. ```
  87. =============coco eval reulst=========
  88. Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.311
  89. Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.528
  90. Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.322
  91. Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.127
  92. Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.323
  93. Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.428
  94. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.259
  95. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.398
  96. Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.423
  97. Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.224
  98. Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.442
  99. Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.551
  100. ```