pascal3d.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:Faster-RCNN_TF 作者: smallcorgi 项目源码 文件源码
def __init__(self, image_set, pascal3d_path = None):
        datasets.imdb.__init__(self, 'pascal3d_' + image_set)
        self._year = '2012'
        self._image_set = image_set
        self._pascal3d_path = self._get_default_path() if pascal3d_path is None \
                            else pascal3d_path
        self._data_path = os.path.join(self._pascal3d_path, 'VOCdevkit' + self._year, 'VOC' + self._year)
        self._classes = ('__background__', # always index 0
                         'aeroplane', 'bicycle', 'boat',
                         'bottle', 'bus', 'car', 'chair',
                         'diningtable', 'motorbike',
                         'sofa', 'train', 'tvmonitor')
        self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes)))
        self._image_ext = '.jpg'
        self._image_index = self._load_image_set_index()
        # Default to roidb handler
        if cfg.IS_RPN:
            self._roidb_handler = self.gt_roidb
        else:
            self._roidb_handler = self.region_proposal_roidb

        # num of subclasses
        if cfg.SUBCLS_NAME == 'voxel_exemplars':
            self._num_subclasses = 337 + 1
        elif cfg.SUBCLS_NAME == 'pose_exemplars':
            self._num_subclasses = 260 + 1
        else:
            assert (1), 'cfg.SUBCLS_NAME not supported!'

        # load the mapping for subcalss to class
        filename = os.path.join(self._pascal3d_path, cfg.SUBCLS_NAME, 'mapping.txt')
        assert os.path.exists(filename), 'Path does not exist: {}'.format(filename)

        mapping = np.zeros(self._num_subclasses, dtype=np.int)
        with open(filename) as f:
            for line in f:
                words = line.split()
                subcls = int(words[0])
                mapping[subcls] = self._class_to_ind[words[1]]
        self._subclass_mapping = mapping

        # PASCAL specific config options
        self.config = {'cleanup'  : True,
                       'use_salt' : True,
                       'top_k'    : 2000}

        # statistics for computing recall
        self._num_boxes_all = np.zeros(self.num_classes, dtype=np.int)
        self._num_boxes_covered = np.zeros(self.num_classes, dtype=np.int)
        self._num_boxes_proposal = 0

        assert os.path.exists(self._pascal3d_path), \
                'PASCAL3D path does not exist: {}'.format(self._pascal3d_path)
        assert os.path.exists(self._data_path), \
                'Path does not exist: {}'.format(self._data_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号