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