(二)Darknet 训练分类网络

目录

1.data文件

2.生成train.list命令

3. train.list

4.train.cfg文件

5.训练网络输出至log文件

6.测试单张图片

7.验证测试集的分类精度

8.可视化log文件


以下使用darknet 训练 mobilenet为例 数据集

1.data文件

classes = 751
train  = data/train.list
valid  = data/val.list
labels = data/market1501_label.txt
backup = backup/mobilet_v3/
top = 5

2.生成train.list命令

find `pwd`/val -name \*.jpg > val.list

(二)Darknet 训练分类网络_第1张图片

3. train.list

/home/darknet_mobilenet/data/train/0002_aabbc0.jpg
/home/darknet_mobilenet/data/train/0002_aabbc1.jpg

 注意:路径中不要出现图像的标签,否则训练时会报错;图片的名字:0002_abc.jpg    _前面为图像的标签,后面最好不要有数字

 训练中报错:Too many or too few labels: 2

详见我的另一篇博客:Too many or too few labels: 2

4.train.cfg文件

[net]

#train
batch=64
subdivisions=16

height=64
width=64
channels=3
momentum=0.9
decay=0.0005
max_crop=64

angle=7
hue = .1
saturation=.75
exposure=.75
aspect=.75

learning_rate=0.1
policy=poly
power=3
max_batches=150000

#conv1 
[convolutional]
batch_normalize=1
filters=32
size=3
stride=2
pad=1
activation=relu

#conv2_1/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv2_1/sep
[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=0
activation=relu


#conv2_2/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=2
pad=1
activation=relu

#conv2_2/sep
[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=0
activation=relu

#conv3_1/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu


#conv3_1/sep
[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=0
activation=relu

#conv3_2/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=2
pad=1
activation=relu

#conv3_2/sep
[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=0
activation=relu

#conv4_1/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv4_1/sep
[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=0
activation=relu

#conv4_2/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=2
pad=1
activation=relu

#conv4_2/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_1/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv5_1/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_2/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv5_2/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_3/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv5_3/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_4/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv5_4/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_5/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv5_5/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#conv5_6/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=2
pad=1
activation=relu

#conv5_6/sep
[convolutional]
batch_normalize=1
filters=1024
size=1
stride=1
pad=0
activation=relu

#conv6/dw
[depthwise_convolutional]
batch_normalize=1
size=3
stride=1
pad=1
activation=relu

#conv6/sep
[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=0
activation=relu

#pool6
[avgpool]

#fc7
[convolutional]
filters=128
size=1
stride=1
pad=0
activation=leaky

#fc8
[convolutional]
filters=751
size=1
stride=1
pad=0
activation=leaky

[softmax]
groups=1

[cost]
type=sse

5.训练网络输出至log文件

./darknet classifier train cfg/market1501.data cfg/mobilenet_1501_train.cfg | tee train_mobilenet.log

6.测试单张图片

./darknet classifier predict cfg/market1501.data cfg/mobilenet_1501_train.cfg backup/mobilenet_1501_train_100.weights data/train/0007_aabbc1.jpg

7.验证测试集的分类精度

./darknet classifier valid cfg/market1501.data cfg/mobilenet_1501_test.cfg backup/mobilet_v2/mobilenet_1501_train_787.weights

8.可视化log文件

(二)Darknet 训练分类网络_第2张图片

(二)Darknet 训练分类网络_第3张图片

 

你可能感兴趣的:(yolo系列,darknet,分类)