mmdetection中的dataset pipline
参考:
轻松掌握 MMDetection 整体构建流程(二)
商汤开源目标检测工具箱mmdetection代码详解(三)----------mmdetection数据的输入、处理过程
1. mmdetection中的数据加载流程
pipline中由一系列数据处理模块对数据集进行流水线般的处理
要注意的是,上述pipline流程在3.x版本中已经有了变化
2.处理模块
2.1 LoadImageFromFile
LoadImageFromFile的主要功能是从图片路径加载一张图片,返回图片数据
的原函数在mmcv包中,路径为mmcv/transforms/loading.py
,该函数的输入参数为:img_path
class LoadImageFromFile(BaseTransform):
"""Load an image from file.
Required Keys:
- img_path
Modified Keys:
- img
- img_shape
- ori_shape
Args:
2.2 LoadAnnotations
主要功能:根据数据集加载并处理“instances”和“seg_map”标注信息
文件路径:mmcv/transforms/loading.py
输入参数:
- instances
- bbox (optional)
- bbox_label
- keypoints (optional)
- seg_map_path (optional)
输出:
- gt_bboxes (np.float32)
- gt_bboxes_labels (np.int64)
- gt_seg_map (np.uint8)
- gt_keypoints (np.float32)
class LoadAnnotations(BaseTransform):
...
2.3 Resize
主要功能:调整图片尺寸
文件路径:/mmcv/transforms/processing.py
输入参数:
- img
- gt_bboxes (optional)
- gt_seg_map (optional)
- gt_keypoints (optional)
会修改的字典信息:
- img
- gt_bboxes
- gt_seg_map
- gt_keypoints
- img_shape
添加信息:
- scale
- scale_factor
- keep_ratio
class Resize(BaseTransform):
...
2.4 RandomFlip
主要功能:翻转图像及其相关的标注(如边界框 bbox、关键点 keypoints 和分割图 segmentation map)
文件路径:/mmcv/transforms/processing.py
输入参数:
- img
- gt_bboxes (optional)
- gt_seg_map (optional)
- gt_keypoints (optional)
会修改的字典信息:
- img
- gt_bboxes (optional)
- gt_seg_map (optional)
- gt_keypoints (optional)
添加信息:
- flip
- flip_direction
- swap_seg_labels (optional)
class RandomFlip(BaseTransform):
...
2.5 PackDetInputs
主要功能:为检测/语义分割/全景分割打包输入数据
文件路径:mmdet/datasets/transforms/formatting.py
输入参数:
-results (dict): Result dict from the data pipeline.
打包并返回:
dict:
- 'inputs' (obj:`torch.Tensor`): The forward data of models.
- 'data_sample' (obj:`DetDataSample`): The annotation info of the
sample.
class PackDetInputs(BaseTransform):
...
Normalize
主要功能:归一化图像
文件路径:/mmcv/transforms/processing.py
输入参数:
- img
会修改的字典信息:
- img
添加信息:
- img_norm_cfg
- mean
- std
- to_rgb
class Normalize(BaseTransform):
...
Pad
主要功能:填充图像和分割图
文件路径:/mmcv/transforms/processing.py
输入参数:
- img
- gt_bboxes (optional)
- gt_seg_map (optional)
会修改的字典信息:
- img
- gt_seg_map
- img_shape
添加信息:
- pad_shape
- pad_fixed_size
- pad_size_divisor
class Pad(BaseTransform):
...