目录结构如下
.txt
文件是由
train_label.py
文件生成的,其他的文件需要根据自己选定的版本yolo版本进行选择.(这里以yolov3-tiny为例)
.txt
train_label.py
修改配置
train_label.py
保修需要的类.然后执行
train_label.py
python train_label.py # 执行后即可出线`.txt`文件,如果遇到报错请查看数据集的位置是否正确.
修改
v3_tiny_obj.names
文件
v3_tiny_obj.names
修改
v3_tiny_obj.data
文件
v3_tiny_obj.data
生成
yolov3-tiny.conv.15
文件 (预训练权重的提取)
yolov3-tiny.conv.15
darknet partial data/voc/yolov3-tiny_obj.cfg data/voc/yolov3-tiny.weights data/voc/yolov3-tiny.conv.15 15
修改
yolov3-tiny_obj.cfg
yolov3-tiny_obj.cfg
锚点计算,普通版本9, tiny 6
darknet detector calc_anchors data/voc/v3_tiny_obj.data -num_of_clusters 6 -width 416 -height 416
修改内容如下
[net]
# Testing
#batch=1
#subdivisions=1
# Training
# 根据电脑性能修改大小, batch = 8*n
batch=64
# 根据电脑性能调整大小
subdivisions=2
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.001
burn_in=1000
#max_batches = 500200
#steps=400000,450000
# 训练步数
max_batches = 10000
policy=steps
# 训练到相应次数后学习率变化
steps=4000,8000
scales=.1,.1
[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=2
[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky
[maxpool]
size=2
stride=1
[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky
###########
[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky
[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky
[convolutional]
size=1
stride=1
pad=1
# classes:训练类别数: filters=3*((classes+5)
filters=18
activation=linear
[yolo]
mask = 3,4,5
# 锚点位置计算
anchors = 23, 63, 57,138, 90,255, 160,179, 165,321, 310,361
# 根据自己设定的类别数修改
classes=1
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
[route]
layers = -4
[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky
[upsample]
stride=2
[route]
layers = -1, 8
[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky
[convolutional]
size=1
stride=1
pad=1
# classes:训练类别数: filters=3*((classes+5)
filters=18
activation=linear
[yolo]
# mask = 0,1,2
mask = 1,2,3
# 锚点位置计算
anchors = 23, 63, 57,138, 90,255, 160,179, 165,321, 310,361
classes=1
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
开始训练
cpu训练
:
cpu训练
在
darknet.exe
所在的路径下打开cmd执行一下命令!!!
darknet.exe
darknet_no_gpu detector train data/voc/v3_tiny_obj.data data/voc/yolov3-tiny_obj.cfg data/voc/yolov3-tiny.conv.15
gpu训练
:
gpu训练
修改工程文件中的
makeFile
文件
makeFile
中修改内容如下
makeFile
开始训练
开始训练
在
darknet.exe
所在的路径下打开cmd执行一下命令!!!
darknet.exe
darknet detector train data/voc/v3_tiny_obj.data data/voc/yolov3-tiny_obj.cfg data/voc/yolov3-tiny.conv.15
训练效果:
训练完权重文件存放路径
版权声明:本文为qq_43619461原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。