log_utils.py 文件源码

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

项目:pybot 作者: spillai 项目源码 文件源码
def roidb(self, target_hash, targets=[], every_k_frames=1, verbose=True, skip_empty=True): 
        """
        @param target_hash: target hash map (name -> unique id)
        @param targets: return only provided target names 

        Returns (img, bbox, targets [hashed with target_hash (int32)])
        """

        self.check_ground_truth_availability()

        if every_k_frames > 1 and skip_empty: 
            raise RuntimeError('roidb not meant for skipping frames,'
                               'and skipping empty simultaneously ')

        # Iterate through all images
        for idx, (t,ch,data) in enumerate(self.iterframes()): 

            # Skip every k frames, if requested
            if idx % every_k_frames != 0: 
                continue

            # Annotations may be empty, if 
            # unlabeled, however we can request
            # to yield if its empty or not
            bboxes = data.annotation.bboxes
            if not len(bboxes) and skip_empty: 
                continue
            target_names = data.annotation.pretty_names

            if len(targets): 
                inds, = np.where([np.any([t in name for t in targets]) for name in target_names])

                target_names = [target_names[ind] for ind in inds]
                bboxes = bboxes[inds]

            yield (data.img, bboxes, np.int32(map(lambda key: target_hash.get(key, -1), target_names)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号