faster RCNN训练出现rpn_box: nan, rcnn_cls: nan, rcnn_box nan

1.数据集有问题,主要存在Xmax>=width,Xmin<=0,Xmax=height,Ymin<=0和Ymax

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]=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

你可能感兴趣的:(深度学习,目标检测,计算机视觉,pytorch,python)