SNIPER/lib/data_utils load_data加载数据

本文介绍SNIPER库中`load_gt_roidb`和`load_proposal_roidb`函数用于加载数据的细节。这两个函数分别处理Ground Truth数据和提议数据,与MXNet加载数据相关。`gt_roidb`返回每个图片的COCO标注集合,而`merge_roidb`用于合并多个数据集。此外,还涉及了数据预处理操作如添加芯片数据、移除小框和过滤数据。参考了相关Python评估博文。
摘要由CSDN通过智能技术生成
  • def load_gt_roidb(dataset_name, image_set_name, root_path, dataset_path, result_path=None, flip=False):

  • def load_proposal_roidb(dataset_name, image_set_name, root_path, dataset_path, result_path=None, proposal=‘rpn’, append_gt=True, flip=False,proposal_path=‘proposals’, only_gt=False, get_imdb=False, load_mask=False):

eval(expression, globals=None, locals=None)  --- 官方文档中的解释是,将字符串str当成有效的表达式来求值并返回计算结果。[1]
    imdb = eval(dataset_name)(image_set_name, root_path, dataset_path, result_path,load_mask=load_mask)

    roidb = imdb.gt_roidb()

imdb.gt_roidb
imdb.py

    def gt_roidb(self):
        raise NotImplementedError

在子类中实现 coco.py coco继承自IMDB

class coco(IMDB):
    def __init__(self, image_set, root_path, data_path, result_path=None, mask_size=-1, binary_thresh=None, load_mask=False):

gt_roidb作用:返回值 gt_roidb,存储三个文件_gt_roidb.pkl, _index_roidb.pkl, _sindex_roidb.pkl, 返回值gt_roidb通过遍历image_set_index中的index,调用self._load_coco_annotation(index),也就是说, roidb其实就是每个图片的coco标注的集合,每个集合元素的形式如下

在这里插入图片描述

gt_roidb实现代码

    def gt_roidb(self):
        cache_file = os.path.join(self.cache_path, self.name + '_gt_roidb.pkl')
        index_file = os.path.join(self.cache_path, self.name + '_index_roidb.pkl')
        sindex_file = os.path.join(self.cache_path, self.name + '_sindex_roidb.pkl')
        if os.path.exists(cache_file) and os.path.exists(index_file):
            with open(cache_file, 'rb') as fid:
                roidb = cPickle.load(fid)
            with open(index_file, 'rb') as fid:
                self.image_set_index = cPickle.load(fid)
            print '{} gt roidb loaded from {}'.format(self.name, cache_file)
    
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
06/06/2023-16:31:47] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) /home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py:166: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. bool: np.bool, Traceback (most recent call last): File "/home/sniper/anaconda3/envs/labelme/bin/yolo", line 8, in <module> sys.exit(entrypoint()) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/cfg/__init__.py", line 398, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 302, in val validator(model=self.model) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/validator.py", line 114, in __call__ model = AutoBackend(model, device=self.device, dnn=self.args.dnn, data=self.args.data, fp16=self.args.half) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/nn/autobackend.py", line 174, in __init__ dtype = trt.nptype(model.get_binding_dtype(i)) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py", line 166, in nptype bool: np.bool, File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations 如何修复
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值