1.数据集有问题,主要存在Xmax>=width,Xmin<=0,Xmax<Xmin,Ymax>=height,Ymin<=0和Ymax<Ymin等情况,需要在lib/datasets/imdb.py中部分段落更改成以下内容:
def _get_widths(self):
return [PIL.Image.open(self.image_path_at(i)).size[0]
for i in range(self.num_images)]
def _get_heights(self):
return [PIL.Image.open(self.image_path_at(i)).size[1]
for i in range(self.num_images)]
def append_flipped_images(self):
num_images = self.num_images
widths = self._get_widths()
heights = self._get_heights()
for i in range(num_images):
boxes = self.roidb[i]['boxes'].copy()
oldx1 = boxes[:, 0].copy()
oldx2 = boxes[:, 2].copy()
# print (self.image_index[i])
assert (boxes[:,1]<=boxes[:,3]).all(),"assert that ymin<=ymax"#assert that ymin<=ymax
assert (boxes[:,1]>=0).all(),"#assert ymin>=0,for 0-based"#assert ymin>=0,for 0-based
assert (boxes[:,3]<heights[i]).all(),"assert ymax<height[i],for 0-based"#assert ymax<height[i],for 0-based
assert (oldx2<widths[i]).all(),"assert xmax<withd[i],for 0-based"#assert xmax<withd[i],for 0-based
assert (oldx1>=0).all(),"assert xmin>=0, for 0-based"#assert xmin>=0, for 0-based
assert (oldx2 >= oldx1).all(),"assert xmax>=xmin, for 0-based"#assert xmax>=xmin, for 0-based
boxes[:, 0] = widths[i] - oldx2 - 1
boxes[:, 2] = widths[i] - oldx1 - 1
# print ("num_image:%d"%(i))
for b in range(len(boxes)):
if boxes[b][2] < boxes[b][0]:
boxes[b][0] = 0
assert (boxes[:, 2] >= boxes[:, 0]).all()
# print(self.image_index[i] + '没问题')
entry = {'boxes': boxes,
'gt_overlaps': self.roidb[i]['gt_overlaps'],
'gt_classes': self.roidb[i]['gt_classes'],
'flipped': True}
self.roidb.append(entry)
self._image_index = self._image_index * 2
之后,根据终端提醒的哪个xml文件存在什么问题,去修改xml文件
2.若上述操作依旧出现问题,则将学习率调成0.001
|