- [Script and Sample Code](#script-and-sample-code)
- [Script Parameters](#script-parameters)
@@ -20,56 +20,51 @@
- [Description of Random Situation](#description-of-random-situation)
- [ModelZoo Homepage](#modelzoo-homepage)
# [YOLOv3-DarkNet53 Description](#contents)
You only look once (YOLO) is a state-of-the-art, real-time object detection system. YOLOv3 is extremely fast and accurate.
You only look once (YOLO) is a state-of-the-art, real-time object detection system. YOLOv3 is extremely fast and accurate.
Prior detection systems repurpose classifiers or localizers to perform detection. They apply the model to an image at multiple locations and scales. High scoring regions of the image are considered detections.
YOLOv3 use a totally different approach. It apply a single neural network to the full image. This network divides the image into regions and predicts bounding boxes and probabilities for each region. These bounding boxes are weighted by the predicted probabilities.
YOLOv3 use a totally different approach. It apply a single neural network to the full image. This network divides the image into regions and predicts bounding boxes and probabilities for each region. These bounding boxes are weighted by the predicted probabilities.
YOLOv3 uses a few tricks to improve training and increase performance, including: multi-scale predictions, a better backbone classifier, and more. The full details are in the paper!
[Paper](https://pjreddie.com/media/files/papers/YOLOv3.pdf): YOLOv3: An Incremental Improvement. Joseph Redmon, Ali Farhadi,
University of Washington
# [Model Architecture](#contents)
YOLOv3 use DarkNet53 for performing feature extraction, which is a hybrid approach between the network used in YOLOv2, Darknet-19, and that newfangled residual network stuff. DarkNet53 uses successive 3 × 3 and 1 × 1 convolutional layers and has some shortcut connections as well and is significantly larger. It has 53 convolutional layers.
# [Dataset](#contents)
Note that you can run the scripts based on the dataset mentioned in original paper or widely used in relevant domain/network architecture. In the following sections, we will introduce how to run the scripts using the related dataset below.
- Note:Data will be processed in yolo_dataset.py, and unzip files before uses it.
# [Environment Requirements](#contents)
- Hardware(Ascend/GPU)
- Prepare hardware environment with Ascend or GPU processor. 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.
- Prepare hardware environment with Ascend or GPU processor. 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.
After installing MindSpore via the official website, you can start training and evaluation in as follows. If running on GPU, please add `--device_target=GPU` in the python command or use the "_gpu" shell script ("xxx_gpu.sh").
```
# The darknet53_backbone.ckpt in the follow script is got from darknet53 training like paper.
```network
# The darknet53_backbone.ckpt in the follow script is got from darknet53 training like paper.
# pretrained_backbone can use src/convert_weight.py, convert darknet53.conv.74 to mindspore ckpt, darknet53.conv.74 can get from `https://pjreddie.com/media/files/darknet53.conv.74` .
# The parameter of training_shape define image shape for network, default is "".
# It means use 10 kinds of shape as input shape, or it can be set some kind of shape.
@@ -78,7 +73,10 @@ python train.py \
--data_dir=./dataset/coco2014 \
--pretrained_backbone=darknet53_backbone.ckpt \
--is_distributed=0 \
--lr=0.1 \
--lr=0.001 \
--loss_scale=1024 \
--sens=1024 \
--weight_decay=0.016 \
--T_max=320 \
--max_epoch=320 \
--warmup_epochs=4 \
@@ -104,17 +102,16 @@ python eval.py \
sh run_eval.sh dataset/coco2014/ checkpoint/0-319_102400.ckpt
```
# [Script Description](#contents)
## [Script and Sample Code](#contents)
```
```contents
.
└─yolov3_darknet53
└─yolov3_darknet53
├─README.md
├─mindspore_hub_conf.md # config for mindspore hub
├─scripts
├─scripts
├─run_standalone_train.sh # launch standalone training(1p) in ascend
├─run_distribute_train.sh # launch distributed training(8p) in ascend
└─run_eval.sh # launch evaluating in ascend
@@ -138,10 +135,9 @@ sh run_eval.sh dataset/coco2014/ checkpoint/0-319_102400.ckpt
└─train.py # train net
```
## [Script Parameters](#contents)
```
```parameters
Major parameters in train.py as follow.
optional arguments:
@@ -179,6 +175,8 @@ optional arguments:
Whether to use label smooth in CE. Default:0
--label_smooth_factor LABEL_SMOOTH_FACTOR
Smooth strength of original one-hot. Default: 0.1
--sens SENS
Static sens. Default: 1024
--log_interval LOG_INTERVAL
Logging interval steps. Default: 100
--ckpt_path CKPT_PATH
@@ -202,18 +200,19 @@ optional arguments:
Resize rate for multi-scale training. Default: None
```
## [Training Process](#contents)
### Training
### Training
```
```command
python train.py \
--data_dir=./dataset/coco2014 \
--pretrained_backbone=darknet53_backbone.ckpt \
--is_distributed=0 \
--lr=0.1 \
--lr=0.001 \
--loss_scale=1024 \
--sens=1024 \
--weight_decay=0.016 \
--T_max=320 \
--max_epoch=320 \
--warmup_epochs=4 \
@@ -225,7 +224,7 @@ The python command above will run in the background, you can view the results th
After training, you'll get some checkpoint files under the outputs folder by default. The loss value will be achieved as follows:
@@ -233,44 +232,46 @@ After training, you'll get some checkpoint files under the outputs folder by def
...
```
The model checkpoint will be saved in outputs directory.
The model checkpoint will be saved in outputs directory.
### Distributed Training
For Ascend device, distributed training example(8p) by shell script
```
```command
sh run_distribute_train.sh dataset/coco2014 darknet53_backbone.ckpt rank_table_8p.json
```
For GPU device, distributed training example(8p) by shell script
```
```command
sh run_distribute_train_gpu.sh dataset/coco2014 darknet53_backbone.ckpt
```
The above shell script will run distribute training in the background. You can view the results through the file `train_parallel[X]/log.txt`. The loss value will be achieved as follows:
Before running the command below. If running on GPU, please add `--device_target=GPU` in the python command or use the "_gpu" shell script ("xxx_gpu.sh").
```
```command
python eval.py \
--data_dir=./dataset/coco2014 \
--pretrained=yolov3.ckpt \
@@ -281,7 +282,7 @@ sh run_eval.sh dataset/coco2014/ checkpoint/0-319_102400.ckpt
The above python command will run in the background. You can view the results through the file "log.txt". The mAP of the test dataset will be as follows:
```
```eval log
# log.txt
=============coco eval reulst=========
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.311
@@ -298,11 +299,11 @@ The above python command will run in the background. You can view the results th
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.551