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.
在这里插入图片描述

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值