From 0ef02be172fb42c67c12b886802e43fe66e5b9fc Mon Sep 17 00:00:00 2001 From: Wuziyi616 Date: Wed, 2 Jun 2021 16:35:23 +0800 Subject: [PATCH] unravel multi-view img to list --- mmdet3d/datasets/pipelines/loading.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mmdet3d/datasets/pipelines/loading.py b/mmdet3d/datasets/pipelines/loading.py index e9ed68190f..e171bb96d7 100644 --- a/mmdet3d/datasets/pipelines/loading.py +++ b/mmdet3d/datasets/pipelines/loading.py @@ -41,12 +41,15 @@ def __call__(self, results): - img_norm_cfg (dict): Normalization configuration of images. """ filename = results['img_filename'] + # img is of shape (h, w, c, num_views) img = np.stack( [mmcv.imread(name, self.color_type) for name in filename], axis=-1) if self.to_float32: img = img.astype(np.float32) results['filename'] = filename - results['img'] = img + # unravel to list, see `DefaultFormatBundle` in formating.py + # which will transpose each image separately and then stack into array + results['img'] = [img[..., i] for i in range(img.shape[-1])] results['img_shape'] = img.shape results['ori_shape'] = img.shape # Set initial values for default meta_keys @@ -61,8 +64,10 @@ def __call__(self, results): def __repr__(self): """str: Return a string that describes the module.""" - return f'{self.__class__.__name__} (to_float32={self.to_float32}, '\ - f"color_type='{self.color_type}')" + repr_str = self.__class__.__name__ + repr_str += f'(to_float32={self.to_float32}, ' + repr_str += f"color_type='{self.color_type}')" + return repr_str @PIPELINES.register_module()