VOCdevkit
VOC2028
Annotations
JPEGImages
ImageSets
Main
cp *.jpg ~/darknet/VOCdevkit/VOC2028/JPEGImages
cp *.xml ~/darknet/VOCdevkit/VOC2028/Annotations
将所有脚本拷贝到cp * ~/darknet/VOCdevkit/VOC2028
cd ~/darknet/VOCdevkit/VOC2028
python3 Main_devide.py /home/town/darknet/VOCdevkit/VOC2028
复制文件 检查图片是否损坏.py 到 VOC2028所在文件夹
终端运行:python3 检查图片是否损坏.py
复制文件 检查XML文件是否出现无效框.py 到 VOC2028所在文件夹
终端运行:python3 检查XML文件是否出现无效框.py
复制文件 对比数量是否一致.py 到 VOC2028所在文件夹
终端运行:python3 对比数量是否一致.py
cp ~/darknet/scripts/voc_label.py ~/darknet
将:sets=[('2012', 'train'), ('2012', 'val'), ('2007', 'train'), ('2007', 'val'), ('2007', 'test')]
改为:sets=[('2028', 'train'), ('2028', 'val'), ('2028', 'test')]
classes=["需要训练的类别名称"]
最后两行:os.system("cat 2007_train.txt 2007_val.txt 2012_train.txt 2012_val.txt > train.txt")
os.system("cat 2007_train.txt 2007_val.txt 2007_test.txt 2012_train.txt 2012_val.txt > train.all.txt")
改为:os.system("cat 2028_train.txt 2028_val.txt > train.txt")
os.system("cat 2028_train.txt 2028_val.txt 2028_test.txt > train.all.txt")
改完后保存,darknet打开终端运行:python3 voc_label.py
复制darknet下的5个新文件到 VOCdevkit 中
cp ~/darknet/cfg/voc.data ~/darknet/VOC_train_core
cp ~/darknet/data/voc.names ~/darknet/VOC_train_core
cp ~/darknet/cfg/yolov3.cfg ~/darknet/VOC_train_core/yolo-obj.cfg
#修改yolo-obj.cfg:
batch=16 (根据显存,或者2的倍数)
subdivisions=16 (根据显存,或者2的倍数)
width=416 (32的倍数)
height=416 (32的倍数)
max_batches = 24000 (类别数量*2000)
steps=19200,21600 (0.8*max_batches,0.9*max_batches)
搜索yolo,有3个地方
filters=39 ( (类别数量+5)*3 )
classes=8 (类别数量)
###batch=64 每batch个样本更新一次参数。
###subdivisions=16 如果内存不够大,将batch分割为subdivisions个子batch,每个子batch的大小为batch/subdivisions。
train = /home/town/darknet/VOCdevkit/train.txt
valid = /home/town/darknet/VOCdevkit/2028_test.txt
names = /home/town/darknet/VOC_train_core/voc.names
backup = /home/town/darknet/backup/
cd ~/darknet
新的训练:
./darknet detector train /home/town/darknet/VOC_train_core/voc.data /home/town/darknet/VOC_train_core/yolo-obj.cfg -map
断点训练:
./darknet detector train /home/town/darknet/VOC_train_core/voc.data /home/town/darknet/VOC_train_core/yolo-obj.cfg /home/town/darknet/backup/yolo-obj_last.weights -map
补充训练:
./darknet detector train /home/town/darknet/VOC_train_core/voc.data /home/town/darknet/VOC_train_core/yolo-obj.cfg /home/town/darknet/backup/yolo-obj_final.weights -clear -map
cd ~/darknet
./darknet detector map /home/town/darknet/VOC_train_core/voc.data /home/town/darknet/VOC_train_core/yolo-obj.cfg /home/town/darknet/backup/yolo-obj_last.weights
备注:
./darknet detector test
./darknet detector train
./darknet detector valid
./darknet detector recall
'<>'必选项,’[ ]‘可选项
data_cfg:数据配置文件,eg:cfg/voc.data
models_cfg:模型配置文件,eg:cfg/yolov3-voc.cfg
weights:权重配置文件,eg:weights/yolov3.weights
test_file:测试文件,eg://*/test.txt
-thresh:显示被检测物体中confidence大于等于 [-thresh] 的bounding-box,默认0.005
-out:输出文件名称,默认路径为results文件夹下,eg:-out “” //输出class_num个文件,文件名为class_name.txt;若不选择此选项,则默认输出文件名为comp4_det_test_“class_name”.txt
-i/-gpu:指定单个gpu,默认为0,eg:-gpu 2
-gpus:指定多个gpu,默认为0,eg:-gpus 0,1,2
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
./darknet detector demo coco.data ./cfg/yolov3.cfg ./yolov3.weights 1.avi