安装配置好yolov4的环境,测试下
用yolov4检测图片:
./darknet detector test cfg/coco.data cfg/yolov4-custom.cfg yolov4.weights -thresh 0.5 ./data/person.jpg
开始用yolov4训练数据集
修改配置文件
1.cfg/目录下复制coco.data,并且重命名为militaryset.data。然后使用修改下面以下内容
classes= 15
train = /home/icra/darknet/militaryset/trainImagePath.txt
valid = /home/icra/darknet/militaryset/validateImagePath.txt
names = /home/icra/darknet/data/militaryset.names
backup = /home/icra/darknet/backup/
2.data/目录下复制coco.names,并且重命名为militaryset.names。改成自己类别的名称
pedestrian
people
bicycle
car
van
truck
tricycle
awning_tricycle
bus
motor
artillery
radar
armored_car
tank
bridge
3.复制cfg/yolov4.cfg,并且重命名为yolo-mil.cfg,同时修改一下内容
[net]
batch=64
subdivisions=16
#Training
#width=512
#height=512
width=416
height=416
channels=3
momentum=0.949
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1
learning_rate=0.0013
burn_in=1000
max_batches = 90000
policy=steps
steps=72000,81000
scales=.1,.1
…
…
[convolutional]
size=1
stride=1
pad=1
filters=60 #三处都改
activation=linear
[yolo]
mask = 0,1,2
anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
classes=15 #三处都改
num=9
jitter=.3
…
完成修改,开始训练。
训练Visdrone数据集
./darknet detector train visdrone.data cfg/yolov4.cfg yolov4.conv.137 -gpu 0,1,2,3
用训练好的权重文件测试图片
./darknet detector test visdrone.data cfg/yolov4.cfg yolov4_final.weights -thresh 0.5 ./data/0001.jpg
以下为个人记录其他数据
./darknet detector train militaryset.data cfg/yolov4-mil.cfg yolov4.conv.137 -gpu 0,1,2,3
用训练好的权重文件测试图片
./darknet detector test militaryset.data cfg/yolov4-mil.cfg yolov4-mil_final.weights -thresh 0.5 ./data/0005.jpg
90000: 3.412004, 3.990894 avg loss, 0.000013 rate, 6.771736 seconds, 5760000 images, 0.132086 hours left
Saving weights to /home/icra/darknet/backup//yolov4-mil_90000.weights
Saving weights to /home/icra/darknet/backup//yolov4-mil_last.weights
Saving weights to /home/icra/darknet/backup//yolov4-mil_final.weights