MMDet——pipline及数据增强模块解析

博主目前在基于mmdet做HD Map的相关工作,因此需要从数据集、pipline以及模型结构各个方面都需要进行重构,而在pipline中,对于之前Detection通用的pipline,需要对Box的GT处理进行变化,以此记录。
首先贴上mmdet官方对pipline的讲解:教程 3: 自定义数据预处理流程
其次贴上另一个大神带图讲解:mmdetection中数据增强的可视化

这里我们仅对train_pipline进行讲解:

train_pipline

train_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(type='LoadAnnotations', with_bbox=True),
    dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
    dict(type='RandomFlip', flip_ratio=0.5),
    dict(type='Normalize', **img_norm_cfg),
    dict(type='Pad', size_divisor=32),
    dict(type='DefaultFormatBundle'),
    dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
  1. LoadImageFromFileLoadAnnotations
    • 从名字就可以知道,这两个method分别是读取imageannotation
    • 一般LoadImageFromFile不需要更改;
    • 如果你的GT不是Object Detection中的box,那么就要重点要更改一下LoadAnnotations函数。

例如我这里的GT是点的形式,那么我就把原先的_load_bboxes改成了_load_pts,同时对里边,只需要把点保存成numpy.array的形式,放进results里边就行了。

	def _load_pts(self, results):
        """Private function to load points annotations.
        Args:
            results (dict): Result dict from :obj:`mmdet.CustomDataset`.
        Returns:
            dict: The dict contains loaded points annotations.
        """
        pts_ego3d_list = []
        for pts_anno in results['ann_info']:
            if self.pts_type == '2D':
                pts_ego3d_list.append(np.array(pts_anno['pts_ego3d'], dtype=np.float32)[:, :2])  
            else:
                pts_ego3d_list.append(np.array(pts_anno['pts_ego3d'], dtype=np.float32))    
        results['gt_pts'] = np.stack(pts_ego3d_list, axis=0)
        return results
        
	def __call__(self, results):
        """Call function to load multiple types annotations.

        Args:
            results (dict): Result dict from :obj:`mmdet.CustomDataset`.

        Returns:
            dict: The dict contains loaded bounding box, label, mask and
                semantic segmentation annotations.
        """
        if self.with_pts:
            results = self._load_pts(results)
        if self.with_label:
            results = self._load_labels(results)
        return results
  1. Resize
    • Resize是对所有的info进行resize,例如imagegt_bboxes等;
    • 主要说一下几个参数:
      • img_scale:配合keep_ratio一起使用;可以是个list,例如img_scale=[(736, 1333), (768, 1333), (800, 1333)],如果keep_ratio=True,那么image和其他的GT都会按照给定img_scale中能够保证图像最大的参数去resize;如果为keep_ratio=False,那么就是按照给定的img_scale分别去resize长和宽。总之,最终的image的对应边尺寸不会大于img_scale给定的任意一边。
      • 参考理解:目标检测中的resize
      • MMDetection 图像缩放 Resize 详细说明
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
  1. RandomFlip
    • RandomFlip是对所有的info进行flip,例如imagegt_bboxes等;
    • 主要说一下几个参数:
      • flip_ratio:每张image做flip的概率。
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值