Using YOLOv2 and YOLOv3 to train your own model on any dataset

Using YOLOv2 to train your model

[YOLO], paper, model was proposed in 2016, as the competitor of faster-RCNN. it play a important role in real-time detection flied, YOLO-Full model processes images in real-time at 45 frames per second using a Tan-X GPU. YOLO-Tiny model processes a astounding 155 frames per second as the some GPU, it`s really fast to meet real-time task.Meanwhile, the accuacy is not enough high, the drawback constraints the its development and complication.
Consequently, The reseracher proposed the modified versions, YOLOv2(YOLO9000),paper, and YOLOv3,paper. YOLOv2 make the accuracy higher at same time stop the running time increasing. YOLOv3 improve the accuracy further, its a little bigger than last time but more accuracy. [link]
so let look how to train those model on your computers and training on your dataset.

Configration

python2 or python3
keras
tensorflow

Training on YOLOv2

Download YOLOv2 source code

you must download the YOLOv2-keras source code on website, Github, the rearched keywords is keras-yolo2, version of experienscor.

Label your own dataset

you can train own dataset, but attention, the version only support the the VOC format dataset, which means you must must annotate your own dataset by the VOC format. so I recommend a software called labelme, The usage of labelme can be found in GIthub by rearch the keyword, labeme, version of wkentro. you can follow the usage of file, example/bbox_detection where introduce the method that convert to VOC format.

Download pretrained weights

there are five kands of pretrained weights, you choose the weight according to your need. When you downloas the Full-yolo pretrain, which is out of date,.Don`t worry about that, please follow the link.

Generate anchors for your dataset (optional)

python3 gen_anchors.py -c config.json

Copy the generated anchors printed on the terminal to the anchors setting in config.json.

Modify the config.json

In order to train your own dataset, you must modify the file config.json. The parameters need to be modified are labels, train_image_folder, train_annot_folder, saved_weights_name. attention: pretrained_weights must be empty, otherwise it will throw a error when the model is training own your dataset . if you find it is out of memory training process. the batch_size can be decrease for relieve the GPU.
Using YOLOv2 and YOLOv3 to train your own model on any dataset_第1张图片

Training on your dataset

python3 train.py -c config.json

By the end of this process, the code will write the weights of the best model to file best_weights.h5 (or whatever name specified in the setting “saved_weights_name” in the config.json file). The training process stops when the loss on the validation set is not improved in 3 consecutive epoches. When you find the process is stopped, but the accruacy is not high, you need to tine a smaller learning rate.

Testing on model

python3 predict.py -c config.json -w /path/to/best_weights.h5 -i /path/to/image/or/video

It carries out detection on the image and write automatically the results file.

你可能感兴趣的:(ubuntu,Yolov2,Yolo,keras,ubuntu,python)