How to train (Pascal VOC Data):
-
2.1 Download file
voc_label.pyto dirbuild\darknet\x\data\voc: -
Download and install Python for Windows:
-
Run command:
python build\darknet\x\data\voc\voc_label.py(to generate files: 2007_test.txt, 2007_train.txt, 2007_val.txt, 2012_train.txt, 2012_val.txt)
(cmd下进入H:\YOLOV3\darknet-master\build\darknet\x\data\voc 运行命令python voc_label.py,之后就会生成下面几个文件)
-
Run command:
type 2007_train.txt 2007_val.txt 2012_*.txt > train.txt
命令的作用就是将四个txt文件合并成一个txt文件(2007_test.txt 训练时不使用) ,所以会生成一个新的 train.txt 文件,文件大小就是前面四个文件的和。
-
Set
batch=andsubdivisions=8in the fileyolov3-voc.cfg:
文件位置:H:\YOLOV3\darknet-master\cfg
-
Start training by using
train_voc.cmdor by using the command line:darknet.exe detector train data/voc.data cfg/yolov3-voc.cfg darknet53.conv.74
我的train_voc.cmd 文件中的代码不是上面这一行,运行会提示找不到 darknet19_48.conv.23。我将原来的代码注释掉了,添加了上面上面这一行代码。
之后双击运行 train_voc.cmd 文件,运行2秒闪退,提示:CUDA Error:out of memory
参考:https:///dcrmg/article/details/78565350 修改如下:
1.GPU=1 CUDNN=1 修改之前都是 0 。
根据训练时需要执行的语句:darknet.exe detector train data/voc.data cfg/yolov3-voc.cfg darknet53.conv.74
voc.data和yolov3-voc.cfg 分别修改成如下:
(如果不修改,或者按照修改成其他文件时会提示:could not open file:darknet19_48.conv.23 或者提示错误: CUDA Error:out of memory )
修改好后,双击运行train_voc.cmd文件,就开始训练了。
截图纪念如下:
(Note: To disable Loss-Window use flag -dont_show. If you are using CPU, try darknet_no_gpu.exe instead of darknet.exe.)
If required change pathes in the file build\darknet\x\data\voc.data
More information about training by the link:
Note: If during training you see nan values for avg (loss) field - then training goes wrong, but if nan is in some other lines - then training goes well.