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

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

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值