Win10 + YOLOv3训练VOC数据集-----How to train Pascal VOC Data

  How to train (Pascal VOC Data):

  1. Download pre-trained weights for the convolutional layers (154 MB): http://pjreddie.com/media/files/darknet53.conv.74and put to the directory builddarknetx64

  2. Download The Pascal VOC Data and unpack it to directory builddarknetx64datavoc will be created dir builddarknetx64datavocVOCdevkit:

              三个文件都要下载每个文件都要解压,右键选择“解压到”,填写解压到的地址:H:YOLOV3darknet-masteruilddarknetx64datavoc

    解压三次,三次“解压到”的地址填的都是同一个。

               

  1. 2.1 Download file voc_label.py to dir builddarknetx64datavochttp://pjreddie.com/media/files/voc_label.py

  2. Download and install Python for Windows: https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe

  3. Run command: python builddarknetx64datavocvoc_label.py (to generate files: 2007_test.txt, 2007_train.txt, 2007_val.txt, 2012_train.txt, 2012_val.txt)

    (cmd下进入H:YOLOV3darknet-masteruilddarknetx64datavoc  运行命令python voc_label.py,之后就会生成下面几个文件)

              

  1. Run command: type 2007_train.txt 2007_val.txt 2012_*.txt > train.txt

    命令的作用就是将四个txt文件合并成一个txt文件(2007_test.txt 训练时不使用) ,所以会生成一个新的 train.txt 文件,文件大小就是前面四个文件的和。

    

  1. Set batch=64 and subdivisions=8 in the file yolov3-voc.cfglink

    文件位置:H:YOLOV3darknet-mastercfg

  1. 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.datayolov3-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 builddarknetx64datavoc.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.

原文地址:https://www.cnblogs.com/yangzhaonan/p/9497887.html