我创建了自己的数据集,该数据集是一组足球图像。由于我只有1个班级,因此我将ball-yolov3-tiny.cfg
修改为将filters
设置为18
,并将classes
设置为1
。
然后,我为图像添加了注释,并将创建的.txt
文件放入图像的同一目录中。最后,我通过执行命令darknet53.conv.74
使用darknet detector train custom/ball-obj.data custom/ball-yolov3-tiny.cfg darknet53.conv.74
模型开始了培训。
我有134张用于训练的图像和15张用于测试的图像。这是培训过程的示例输出:
95: 670.797241, 597.741333 avg, 0.000000 rate, 313.254830 seconds, 6080 images
Loaded: 0.000302 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499381, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.496005, No Obj: 0.496541, .5R: 0.000000, .75R: 0.000000, count: 32
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499381, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.496005, No Obj: 0.496541, .5R: 0.000000, .75R: 0.000000, count: 32
96: 670.557190, 605.022949 avg, 0.000000 rate, 312.962750 seconds, 6144 images
Loaded: 0.000272 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499360, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.495868, No Obj: 0.496454, .5R: 0.000000, .75R: 0.000000, count: 32
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499360, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.495868, No Obj: 0.496454, .5R: 0.000000, .75R: 0.000000, count: 32
97: 670.165161, 611.537170 avg, 0.000000 rate, 312.681998 seconds, 6208 images
Loaded: 0.000282 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499331, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.495722, No Obj: 0.496397, .5R: 0.000000, .75R: 0.000000, count: 32
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499331, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344946, Class: 0.498204, Obj: 0.495722, No Obj: 0.496397, .5R: 0.000000, .75R: 0.000000, count: 32
98: 669.815918, 617.365051 avg, 0.000000 rate, 319.203044 seconds, 6272 images
Loaded: 0.000244 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499294, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344947, Class: 0.498204, Obj: 0.495569, No Obj: 0.496253, .5R: 0.000000, .75R: 0.000000, count: 32
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499294, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344947, Class: 0.498204, Obj: 0.495569, No Obj: 0.496253, .5R: 0.000000, .75R: 0.000000, count: 32
99: 669.555664, 622.584106 avg, 0.000000 rate, 320.330266 seconds, 6336 images
Loaded: 0.000244 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499246, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344948, Class: 0.498204, Obj: 0.495409, No Obj: 0.496197, .5R: 0.000000, .75R: 0.000000, count: 32
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499246, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.344948, Class: 0.498204, Obj: 0.495409, No Obj: 0.496197, .5R: 0.000000, .75R: 0.000000, count: 32
100: 669.132629, 627.238953 avg, 0.000000 rate, 329.954091 seconds, 6400 images
Saving weights to backup//ball-yolov3-tiny.backup
Saving weights to backup//ball-yolov3-tiny_100.weights
Resizing
576
Loaded: 1.764142 seconds
Region 16 Avg IOU: -nan, Class: -nan, Obj: -nan, No Obj: 0.499216, .5R: -nan, .75R: -nan, count: 0
Region 23 Avg IOU: 0.430712, Class: 0.498203, Obj: 0.495251, No Obj: 0.496154, .5R: 0.000000, .75R: 0.000000, count: 32
以下是其他配置文件:
ball-obj.data
classes= 1
train = custom/ball-train.txt
valid = custom/ball-test.txt
names = custom/ball-obj.names
backup = backup/
ball-obj.names
ball
当我使用创建的权重来测试单个图像时,它根本无法在图像中找到足球。我是否需要更多(例如10K)图像?还是我需要长时间训练模型?我只想确保有关我的设置的所有信息都可以。
请随时询问有关我的实验的任何疑问。非常感谢您的帮助。预先感谢。
p.s。这是我的ball-yolov3-tiny.cnf
的全部内容:
[net]
# Testing
batch=1
subdivisions=1
# Training
#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
policy=steps
steps=400000,450000
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
filters=18
activation=linear
[yolo]
mask = 3,4,5
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
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
filters=18
activation=linear
[yolo]
mask = 0,1,2
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
classes=1
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
我执行的命令是:
darknet detector train custom/ball-obj.data custom/ball-yolov3-tiny.cfg darknet53.conv.74
答案 0 :(得分:1)
batch=1 subdivisions=1
意味着您每1次迭代仅训练1张图片,如果您有足够的GPU,则可以尝试增加数量以使模型收敛得更好100: 669.132629, 627.238953 avg
。您会看到平均损失 627.238953 ,该损失太大。好的YOLO模型损失约0.06〜1。 因此,根据以上几点,您可以做的是继续训练(对于Tiny YOLO而言,仅进行100次迭代是不够的),增加批次和细分并增加数据集。
添加:使用数据集重新计算边界框也是一个不错的选择,您可以在互联网上找到很多很棒的示例和代码。
答案 1 :(得分:1)
max_batches= (# of classes)* 2000
max_batches = 6000
如果你训练 1、2、3 节课,那将是 6000
和
Steps=(80% of max_batches),(90% of max_batches) i.e,
steps=4800,5400
答案 2 :(得分:0)
将批处理大小增加到64,并使用尽可能少的细分来满足GPU内存的需要:如果继续使CUDA内存不足,请从1、2、4、8、16、32开始,最后是64。 >
您应该训练自己的网络,直到平均丢失率小于1。
您使用的是约瑟夫·雷德蒙斯仓库中原始版本的Darknet,还是使用叉子?对于如何改善对象检测here,有一系列建议,但是,我不确定它们是否适用于所有其他版本。