コード例 #1
0
    def selective_search_roidb(self):  # 已经修改
        """
        Return the database of selective search regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + '_selective_search_roidb.pkl')

        if os.path.exists(cache_file):  # 若存在cache_file则读取相对应的.pkl文件
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} ss roidb loaded from {}'.format(self.name, cache_file)
            return roidb
        if self._image_set != 'soton_ear':
            gt_roidb = self.gt_roidb()
            ss_roidb = self._load_selective_search_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        else:
            gt_roidb = self.gt_roidb()
            roidb = self._load_selective_search_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, roidb)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote ss roidb to {}'.format(cache_file)

        return roidb
コード例 #2
0
    def selective_search_roidb(self):
        """
        Return the database of selective search regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + "_selective_search_roidb.pkl")

        if os.path.exists(cache_file):
            with open(cache_file, "rb") as fid:
                roidb = cPickle.load(fid)
            print "{} ss roidb loaded from {}".format(self.name, cache_file)
            return roidb

        if int(self._year) == 2007 or self._image_set != "test":
            gt_roidb = self.gt_roidb()
            ss_roidb = self._load_selective_search_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        else:
            roidb = self._load_selective_search_roidb(None)
        with open(cache_file, "wb") as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print "wrote ss roidb to {}".format(cache_file)

        return roidb
コード例 #3
0
ファイル: coco.py プロジェクト: ming8924/py-faster-rcnn
    def _roidb_from_proposals(self, method):
        """
        Creates a roidb from pre-computed proposals of a particular methods.
        """
        top_k = self.config['top_k']
        cache_file = osp.join(self.cache_path, self.name +
                              '_{:s}_top{:d}'.format(method, top_k) +
                              '_roidb.pkl')

        if osp.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{:s} {:s} roidb loaded from {:s}'.format(self.name, method,
                                                            cache_file)
            return roidb

        if self._image_set in self._gt_splits:
            gt_roidb = self.gt_roidb()
            method_roidb = self._load_proposals(method, gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, method_roidb)
            # Make sure we don't use proposals that are contained in crowds
            roidb = _filter_crowd_proposals(roidb, self.config['crowd_thresh'])
        else:
            roidb = self._load_proposals(method, None)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote {:s} roidb to {:s}'.format(method, cache_file)
        return roidb
コード例 #4
0
    def selective_search_roidb(self):
        """
        Return the database of selective search regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path,
                                  self.name + '_selective_search_roidb.pkl')
        #cache_file = '/home/py-faster-rcnn/output/faster_rcnn_alt_opt/voc_2007_test/zf_rpn_stage1_iter_80000/zf_rpn_stage1_iter_80000_rpn_proposals.pkl'

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} ss roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            ss_roidb = self._load_selective_search_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        else:
            roidb = self._load_selective_search_roidb(None)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote ss roidb to {}'.format(cache_file)

        return roidb
コード例 #5
0
 def rpn_roidb(self):
       if self._image_set != 'test':
           gt_roidb = self.gt_roidb()
           rpn_roidb = self._load_rpn_roidb(gt_roidb)
           roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
       else:
           roidb = self._load_rpn_roidb(None)
       return roidb
コード例 #6
0
ファイル: traffic.py プロジェクト: gunnarsnorri/babybackribs
 def rpn_roidb(self):
     if self.name != "test":
         gt_roidb = self.gt_roidb()
         ss_roidb = self._load_selective_search_roidb(gt_roidb)
         roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
     else:
         roidb = self._load_selective_search_roidb(None)
     return roidb
コード例 #7
0
    def rpn_roidb(self):
        if self._image_set != 'test-all02':  #initially test-all
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #8
0
  def rpn_roidb(self):                              #使用rpn_roidb这种method从imdb中获取roidb数据
    if int(self._year) == 2007 or self._image_set != 'test':     #数据集名称包含2007年且不是test数据集可以使用这种method
      gt_roidb = self.gt_roidb()                    #获得ground_truth的roidb,其实是xml解析的
      rpn_roidb = self._load_rpn_roidb(gt_roidb)    #生成rpn_roidb
      roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)#融合
    else:
      roidb = self._load_rpn_roidb(None)

    return roidb
コード例 #9
0
    def rpn_roidb(self):  # CHECKED!
        if self._name == '2007' or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #10
0
    def rpn_roidb(self):
        # if int(self._year) == 2007 or self._image_set != 'test':
        gt_roidb = self.gt_roidb()
        rpn_roidb = self._load_rpn_roidb(gt_roidb)
        roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        # else:
        #     roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #11
0
ファイル: coco.py プロジェクト: intel/caffe
    def rpn_roidb(self):
        if (self._image_set != 'val') and ('test' not in self._image_set):
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #12
0
    def rpn_roidb(self):
        if (self._image_set != 'val') and ('test' not in self._image_set):
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #13
0
  def rpn_roidb(self):
    if int(self._year) == 2017 or self._image_set != 'debug':
      gt_roidb = self.gt_roidb()
      rpn_roidb = self._load_rpn_roidb(gt_roidb)
      roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
    else:
      roidb = self._load_rpn_roidb(None)

    return roidb
    def rpn_roidb(self):
        if self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #15
0
    def pkl_roidb(self):
        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            pkl_roidb = self._load_pkl_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, pkl_roidb)
        else:
            roidb = self._load_pkl_roidb(None)

        return roidb
コード例 #16
0
    def rpn_roidb(self):
        if int(self._year) == 2007 or self._split != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #17
0
    def rpn_roidb(self):
        if int(self._year) == 2007 or self._image_set != "test":
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #18
0
    def rpn_roidb(self):
        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            #govind: For testing, 
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #19
0
    def rpn_roidb(self):
        if self._year == 'ak47' or int(self._year) != 2006 or  \
          self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #20
0
    def rpn_roidb(self):
        # 训练时:
        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            # 这个rpn_roidb是模型生成的吗???
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        # 测试时:直接使用roidb
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #21
0
    def rpn_roidb(self):
        """
        该方法首先 --->  1、调用gt_roidb(),生成gt_roidb
                        2、调用_load_rpn_roidb(gt_roidb)载入rpn_roidb,
                                而具体的_load_rpn_roidb()是调用其父类imdb的create_roidb_from_box_list()中获取每张图片的boxes
                        3、调用父类imdb的merge_roidbs()方法将gt_roidb和rpn_roidb合并为一个roidb
    """
        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)

        return roidb
コード例 #22
0
    def region_proposal_roidb(self):
        """
        Return the database of regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(
            self.cache_path, self.name + '_' + cfg.SUBCLS_NAME + '_' +
            cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print('{} roidb loaded from {}'.format(self.name, cache_file))
            return roidb

        if self._image_set != 'testing':
            gt_roidb = self.gt_roidb()

            print('Loading region proposal network boxes...')
            if self._image_set == 'trainval':
                model = cfg.REGION_PROPOSAL + '_trainval/'
            else:
                model = cfg.REGION_PROPOSAL + '_train/'
            rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
            print('Region proposal network boxes loaded')
            roidb = imdb.merge_roidbs(rpn_roidb, gt_roidb)
        else:
            print('Loading region proposal network boxes...')
            model = cfg.REGION_PROPOSAL + '_trainval/'
            roidb = self._load_rpn_roidb(None, model)
            print('Region proposal network boxes loaded')

        print('{} region proposals per image'.format(self._num_boxes_proposal /
                                                     len(self.image_index)))

        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print('wrote roidb to {}'.format(cache_file))

        return roidb
コード例 #23
0
ファイル: pascal_voc.py プロジェクト: zhucer2003/dl-course
    def rpn_roidb(self):
        cache_file = os.path.join(self.cache_path,
                                  self.name + '_rpn_roidb.pkl')

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} rpn roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote rpn roidb to {}'.format(cache_file)

        return roidb
コード例 #24
0
ファイル: pascal_voc.py プロジェクト: AlexFridman/dl-course
    def rpn_roidb(self):
        cache_file = os.path.join(self.cache_path,
                                  self.name + '_rpn_roidb.pkl')

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            print '{} rpn roidb loaded from {}'.format(self.name, cache_file)
            return roidb

        if int(self._year) == 2007 or self._image_set != 'test':
            gt_roidb = self.gt_roidb()
            rpn_roidb = self._load_rpn_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
        else:
            roidb = self._load_rpn_roidb(None)
        with open(cache_file, 'wb') as fid:
            cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
        print 'wrote rpn roidb to {}'.format(cache_file)

        return roidb
コード例 #25
0
    def selective_search_IJCV_roidb(self):
        """
        eturn the database of selective search regions of interest.
        Ground-truth ROIs are also included.
        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(
            self.cache_path,
            '{:s}_selective_search_IJCV_top_{:d}_roidb.pkl'.format(
                self.name, self.config['top_k']))

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = pickle.load(fid)
            print('{} ss roidb loaded from {}'.format(self.name, cache_file))
            return roidb

        gt_roidb = self.gt_roidb()
        ss_roidb = self._load_selective_search_IJCV_roidb(gt_roidb)
        roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        with open(cache_file, 'wb') as fid:
            pickle.dump(roidb, fid, pickle.HIGHEST_PROTOCOL)

        return roidb
コード例 #26
0
 def rpn_roidb(self):
     gt_roidb = self.gt_roidb()
     rpn_roidb = self._load_rpn_roidb(gt_roidb)
     roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
     #roidb = self._load_rpn_roidb(None)
     return roidb
コード例 #27
0
ファイル: letters.py プロジェクト: Ethiy/py-faster-rcnn
 def rpn_roidb(self):
     gt_roidb = self.gt_roidb()
     rpn_roidb = self._load_rpn_roidb(gt_roidb)
     roidb = imdb.merge_roidbs(gt_roidb, rpn_roidb)
     return roidb