Skip to content

Commit

Permalink
add support for resizing multiple sem segs (open-mmlab#5747)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarborYuan authored Sep 27, 2021
1 parent d53fbbc commit a1ab8d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mmdet/datasets/pipelines/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def _resize_seg(self, results):
results['scale'],
interpolation='nearest',
backend=self.backend)
results['gt_semantic_seg'] = gt_seg
results[key] = gt_seg

def __call__(self, results):
"""Call function to resize images, bounding boxes, masks, semantic
Expand Down
22 changes: 22 additions & 0 deletions tests/test_data/test_pipelines/test_transform/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,28 @@ def test_resize():
assert results['img_shape'] == (800, 1280, 3)
assert results['img'].dtype == results['img'].dtype == np.uint8

results_seg = {
'img': img,
'img_shape': img.shape,
'ori_shape': img.shape,
'gt_semantic_seg': copy.deepcopy(img),
'gt_seg': copy.deepcopy(img),
'seg_fields': ['gt_semantic_seg', 'gt_seg']
}
transform = dict(
type='Resize',
img_scale=(640, 400),
multiscale_mode='value',
keep_ratio=False)
resize_module = build_from_cfg(transform, PIPELINES)
results_seg = resize_module(results_seg)
assert results_seg['gt_semantic_seg'].shape == results_seg['gt_seg'].shape
assert results_seg['img_shape'] == (400, 640, 3)
assert results_seg['img_shape'] != results_seg['ori_shape']
assert results_seg['gt_semantic_seg'].shape == results_seg['img_shape']
assert np.equal(results_seg['gt_semantic_seg'],
results_seg['gt_seg']).all()


def test_flip():
# test assertion for invalid flip_ratio
Expand Down

0 comments on commit a1ab8d1

Please sign in to comment.