Skip to content

Commit

Permalink
unravel multi-view img to list
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuziyi616 committed Jun 2, 2021
1 parent d5bddd2 commit 0ef02be
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mmdet3d/datasets/pipelines/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 0ef02be

Please sign in to comment.