Win10 + YOLOv3训练VOC数据集-----How to train Pascal VOC Data
How to train (Pascal VOC Data):
-
Download pre-trained weights for the convolutional layers (154 MB): http://pjreddie.com/media/files/darknet53.conv.74and put to the directory
build\darknet\x64
-
Download The Pascal VOC Data and unpack it to directory
build\darknet\x64\data\voc
will be created dirbuild\darknet\x64\data\voc\VOCdevkit\
:
三个文件都要下载每个文件都要解压,右键选择“解压到”,填写解压到的地址:H:\YOLOV3\darknet-master\build\darknet\x64\data\voc
解压三次,三次“解压到”的地址填的都是同一个。
-
2.1 Download file
voc_label.py
to dirbuild\darknet\x64\data\voc
: http://pjreddie.com/media/files/voc_label.py -
Download and install Python for Windows: https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
-
Run command:
python build\darknet\x64\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\x64\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=64
andsubdivisions=8
in the fileyolov3-voc.cfg
: link
文件位置:H:\YOLOV3\darknet-master\cfg
-
Start training by using
train_voc.cmd
or 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://blog.csdn.net/dcrmg/article/details/78565350 修改如下:
1.GPU=1 CUDNN=1 修改之前都是 0 。
根据训练时需要执行的语句:darknet.exe detector train data/voc.data cfg/yolov3-voc.cfg darknet53.conv.74
来修改对应文件中的代码(注意:darknet官网所给的voc.data文件位置是错误的的,这两个需要修改的文件都应该和 train_voc.cmd文件 在相同的目录下):
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\x64\data\voc.data
More information about training by the link: http://pjreddie.com/darknet/yolo/#train-voc
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.
posted @ 2018-08-18 17:23 YangZhaonan 阅读(...) 评论(...) 编辑 收藏