Note: if error Out of memory occurs then in .cfg-file you should increase subdivisions=16, 32 or 64: link
How to train tiny-yolo (to detect your custom objects):Do all the same steps as for the full yolo model as described above. With the exception of:
- Download file with the first 29-convolutional layers of yolov4-tiny: https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.conv.29 (Or get this file from yolov4-tiny.weights file by using command: darknet.exe partial cfg/yolov4-tiny.cfg yolov4-tiny.weights yolov4-tiny.conv.29 29
- Make your custom model yolov4-tiny-obj.cfg based on cfg/yolov4-tiny.cfg instead of yolov4.cfg
- Start training: darknet.exe detector train data/obj.data yolov4-tiny-obj.cfg yolov4-tiny.conv.29
When should I stop training:Usually sufficient 2000 iterations for each class(object), but not less than number of training images and not less than 6000 iterations in total. But for a more precise definition when you should stop training, use the following manual:
- During training, you will see varying indicators of error, and you should stop when no longer decreases 0.XXXXXXX avg:
Region Avg IOU: 0.798363, Class: 0.893232, Obj: 0.700808, No Obj: 0.004567, Avg Recall: 1.000000, count: 8 Region Avg IOU: 0.800677, Class: 0.892181, Obj: 0.701590, No Obj: 0.004574, Avg Recall: 1.000000, count: 8
9002: 0.211667, 0.60730 avg, 0.001000 rate, 3.868000 seconds, 576128 images Loaded: 0.000000 seconds
- 9002 - iteration number (number of batch)
- 0.60730 avg - average loss (error) - the lower, the better
Or if you train with flag -map then you will see mAP indicator Last accuracy mAP@0.5 = 18.50% in the console - this indicator is better than Loss, so train while mAP increases.
- Once training is stopped, you should take some of last .weights-files from darknetbuilddarknet\x64backup and choose the best of them:
文章插图
To get weights from Early Stopping Point:
2.1. At first, in your file obj.data you must specify the path to the validation dataset valid = valid.txt (format of valid.txt as in train.txt), and if you haven't validation images, just copy datatrain.txt to datavalid.txt.
2.2 If training is stopped after 9000 iterations, to validate some of previous weights use this commands:
(If you use another GitHub repository, then use darknet.exe detector recall... instead of darknet.exe detector map...)
- darknet.exe detector map data/obj.data yolo-obj.cfg backupyolo-obj_7000.weights
- darknet.exe detector map data/obj.data yolo-obj.cfg backupyolo-obj_8000.weights
- darknet.exe detector map data/obj.data yolo-obj.cfg backupyolo-obj_9000.weights
Choose weights-file with the highest mAP (mean average precision) or IoU (intersect over union)
For example, bigger mAP gives weights yolo-obj_8000.weights - then use this weights for detection.
Or just train with -map flag:
darknet.exe detector train data/obj.data yolo-obj.cfg yolov4.conv.137 -map
So you will see mAP-chart (red-line) in the Loss-chart Window. mAP will be calculated for each 4 Epochs using valid=valid.txt file that is specified in obj.data file (1 Epoch = images_in_train_txt / batch iterations)
(to change the max x-axis value - change max_batches= parameter to 2000*classes, f.e. max_batches=6000 for 3 classes)
文章插图
Example of custom object detection: darknet.exe detector test data/obj.data yolo-obj.cfg yolo-obj_8000.weights
- IoU (intersect over union) - average instersect over union of objects and detections for a certain threshold = 0.24
推荐阅读
- windows.old可以删除吗?
- 一个可放大图像的开源的浏览器扩展
- 新windows勒索软件变种,通过USB驱动横向传播
- 让Mac电脑读取NTFS硬盘的免费开源的软件
- 9个优秀的 VUE 开源项目
- Win 10系统盘突然满了,不下载第三方软件,应该怎么清理?
- CentOS7上安装与配置开源堡垒机Teleport
- 全球知名25种开源情报库
- Win7家庭版如何给文件夹设置密码?Win7文件夹加密方法
- Ubuntu安装及配置