【问题标题】:How to train new fast-rcnn imageset如何训练新的 fast-rcnn 图像集
【发布时间】:2015-09-09 09:51:09
【问题描述】:

我正在使用 fast-rcnn 并尝试为新课程(标签)训练系统 我跟着这个:https://github.com/EdisonResearch/fast-rcnn/tree/master/help/train

  1. 放置图片

  2. 放置注释

  3. 准备带有所有图像名称前缀的ImageSet

  4. 准备的选择性搜索输出:train.mat

我在运行 train_net.py 时失败,出现以下错误:

./tools/train_net.py --gpu 0 --solver models/VGG_1024_pascal2007/solver.prototxt --imdb voc_2007_train_top_5000 

Called with args: Namespace(cfg_file=None, gpu_id=0, imdb_name='voc_2007_train_top_5000', max_iters=40000, pretrained_model=None, randomize=False, solver='models/VGG_1024_pascal2007/solver.prototxt') Using config: {'DEDUP_BOXES': 0.0625,  'EPS': 1e-14,  'EXP_DIR': 'default',  'PIXEL_MEANS': array([[[ 102.9801,  115.9465,  122.7717]]]),  'RNG_SEED': 3,  'ROOT_DIR': '/home/hagay/fast-rcnn',  'TEST': {'BBOX_REG': True,
          'MAX_SIZE': 1000,
          'NMS': 0.3,
          'SCALES': [600],
          'SVM': False},  'TRAIN': {'BATCH_SIZE': 128,
           'BBOX_REG': True,
           'BBOX_THRESH': 0.5,
           'BG_THRESH_HI': 0.5,
           'BG_THRESH_LO': 0.1,
           'FG_FRACTION': 0.25,
           'FG_THRESH': 0.5,
           'IMS_PER_BATCH': 2,
           'MAX_SIZE': 1000,
           'SCALES': [600],
           'SNAPSHOT_INFIX': '',
           'SNAPSHOT_ITERS': 10000,
           'USE_FLIPPED': True,
           'USE_PREFETCH': False}} Loaded dataset `voc_2007_train` for training Appending horizontally-flipped training examples... voc_2007_train gt roidb loaded from /home/hagay/fast-rcnn/data/cache/voc_2007_train_gt_roidb.pkl /usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py:2507: VisibleDeprecationWarning: `rank` is deprecated; use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.   VisibleDeprecationWarning) wrote ss roidb to /home/hagay/fast-rcnn/data/cache/voc_2007_train_selective_search_IJCV_top_5000_roidb.pkl Traceback (most recent call last):   File "./tools/train_net.py", line 80, in <module>
    roidb = get_training_roidb(imdb)   File "/home/hagay/fast-rcnn/tools/../lib/fast_rcnn/train.py", line 107, in get_training_roidb
    imdb.append_flipped_images()   File "/home/hagay/fast-rcnn/tools/../lib/datasets/imdb.py", line 104, in append_flipped_images
    assert (boxes[:, 2] >= boxes[:, 0]).all() AssertionError

我的问题是:

  1. 为什么会出现此错误?
  2. 是否需要在训练前重新缩放图像以修复:256x256?
  3. 为了设置__background__类,我需要准备一些东西吗?

【问题讨论】:

  • 问题解决了吗?我也有兴趣在 ImageNet 上进行培训。

标签: python neural-network caffe


【解决方案1】:
  1. 它说存在boxes[:,2] &lt; boxes[:, 0]boxes[:, 2]是边界框的x-max,而boxes[:, 0]是x-min。所以这个问题与区域提案有关。我也遇到过这个问题。我发现这是溢出的原因。我记得 box 的 dtype 是 np.uint8(需要检查),如果图像太大,你会得到这个错误。
  2. 重新调整是一种解决方案,但这可能会影响性能。您可以将 dtype 从 uint8 更改为 float。
  3. 据我所知,没有必要这样做。

【讨论】:

    【解决方案2】:

    我参加聚会迟到了,但是当我编辑代码时,这是我的 yakkity-hack 解决方案

            for b in range(len(boxes)):
                if boxes[b][2] < boxes[b][0]:
                    boxes[b][0] = 0
            assert (boxes[:, 2] >= boxes[:, 0]).all()
    

    正如每个研究生似乎都指出的那样,有更聪明的方法可以做到这一点,但这很好用。

    【讨论】:

      【解决方案3】:

      查看以下博客文章第 4 部分,问题 #4 中描述的解决方案。解决方法是翻转x1和x2坐标值。

      https://huangying-zhan.github.io/2016/09/22/detection-faster-rcnn.html

      以下复制自链接:

      框[:, 0] > 框[:, 2]

      解决方法:在imdb.py中添加如下代码块

      def append_flipped_images(self):
      num_images = self.num_images
      widths = self._get_widths()
      for i in xrange(num_images):
          boxes = self.roidb[i]['boxes'].copy()
          oldx1 = boxes[:, 0].copy()
          oldx2 = boxes[:, 2].copy()
          boxes[:, 0] = widths[i] - oldx2
          boxes[:, 2] = widths[i] - oldx1
          for b in range(len(boxes)):
                  if boxes[b][2] < boxes[b][0]:
                      boxes[b][0]=0
          assert (boxes[:, 2] >= boxes[:, 0]).all()
      

      【讨论】:

        猜你喜欢
        • 2020-01-11
        • 2018-05-06
        • 2018-02-04
        • 2020-07-25
        • 1970-01-01
        • 2020-02-05
        • 2017-07-27
        • 2019-11-17
        • 2020-03-31
        相关资源
        最近更新 更多