So if classes=1 then should be filters=18. If classes=2 then write filters=21.
(Do not write in the cfg-file: filters=(classes + 5)x3)
(Generally filters depends on the classes, coords and number of masks, i.e. filters=(classes + coords + 1)*<number of mask>, where mask is indices of anchors. If mask is absence, then filters=(classes + coords + 1)*num)
So for example, for 2 objects, your file yolo-obj.cfg should differ from yolov4-custom.cfg in such lines in each of 3 [yolo]-layers:
[convolutional]filters=21[region]classes=2
- Create file obj.names in the directory builddarknet\x64data, with objects names - each in new line
- Create file obj.data in the directory builddarknet\x64data, containing (where classes = number of objects):
classes= 2train= data/train.txtvalid= data/test.txtnames = data/obj.namesbackup = backup/
- Put image-files (.jpg) of your objects in the directory builddarknet\x64dataobj
- You should label each object on images from your dataset. Use this visual GUI-software for marking bounded boxes of objects and generating annotation files for Yolo v2 & v3: https://github.com/AlexeyAB/Yolo_mark
<object-class> <x_center> <y_center> <width> <height>
Where:
- <object-class> - integer object number from 0 to (classes-1)
- <x_center> <y_center> <width> <height> - float values relative to width and height of image, it can be equal from (0.0 to 1.0]
- for example: <x> = <absolute_x> / <image_width> or <height> = <absolute_height> / <image_height>
- atention: <x_center> <y_center> - are center of rectangle (are not top-left corner)
1 0.716797 0.395833 0.216406 0.1472220 0.687109 0.379167 0.255469 0.1583331 0.420312 0.395833 0.140625 0.166667
- Create file train.txt in directory builddarknet\x64data, with filenames of your images, each filename in new line, with path relative to darknet.exe, for example containing:
data/obj/img1.jpgdata/obj/img2.jpgdata/obj/img3.jpg
- Download pre-trained weights for the convolutional layers and put to the directory builddarknet\x64for yolov4.cfg, yolov4-custom.cfg (162 MB): yolov4.conv.137 (Google drive mirror yolov4.conv.137 )for csresnext50-panet-spp.cfg (133 MB): csresnext50-panet-spp.conv.112for yolov3.cfg, yolov3-spp.cfg (154 MB): darknet53.conv.74for yolov3-tiny-prn.cfg , yolov3-tiny.cfg (6 MB): yolov3-tiny.conv.11for enet-coco.cfg (EfficientNetB0-Yolov3) (14 MB): enetb0-coco.conv.132
- Start training by using the command line: darknet.exe detector train data/obj.data yolo-obj.cfg yolov4.conv.137To train on Linux use command: ./darknet detector train data/obj.data yolo-obj.cfg yolov4.conv.137 (just use ./darknet instead of darknet.exe)(file yolo-obj_last.weights will be saved to the builddarknet\x64backup for each 100 iterations)(file yolo-obj_xxxx.weights will be saved to the builddarknet\x64backup for each 1000 iterations)(to disable Loss-Window use darknet.exe detector train data/obj.data yolo-obj.cfg yolov4.conv.137 -dont_show, if you train on computer without monitor like a cloud Amazon EC2)(to see the mAP & Loss-chart during training on remote server without GUI, use command darknet.exe detector train data/obj.data yolo-obj.cfg yolov4.conv.137 -dont_show -mjpeg_port 8090 -map then open URL http://ip-address:8090 in Chrome/Firefox browser)
- After training is complete - get result yolo-obj_final.weights from path builddarknet\x64backup
- After each 100 iterations you can stop and later start training from this point. For example, after 2000 iterations you can stop training, and later just start training using: darknet.exe detector train data/obj.data yolo-obj.cfg backupyolo-obj_2000.weights(in the original repository https://github.com/pjreddie/darknet the weights-file is saved only once every 10 000 iterations if(iterations > 1000))
- Also you can get result earlier than all 45000 iterations.
Note: If you changed width= or height= in your cfg-file, then new width and height must be divisible by 32.
Note: After training use such command for detection: darknet.exe detector test data/obj.data yolo-obj.cfg yolo-obj_8000.weights
推荐阅读
- windows.old可以删除吗?
- 一个可放大图像的开源的浏览器扩展
- 新windows勒索软件变种,通过USB驱动横向传播
- 让Mac电脑读取NTFS硬盘的免费开源的软件
- 9个优秀的 VUE 开源项目
- Win 10系统盘突然满了,不下载第三方软件,应该怎么清理?
- CentOS7上安装与配置开源堡垒机Teleport
- 全球知名25种开源情报库
- Win7家庭版如何给文件夹设置密码?Win7文件夹加密方法
- Ubuntu安装及配置