[Fix] Fix ResizeToMultiple transform in MMSeg 1.x (#2185)
parent
84e76492b9
commit
f3cd44bebf
|
@ -77,20 +77,13 @@ using `AlignedResize`, you can change the dataset pipeline like this:
|
|||
```python
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2048, 512),
|
||||
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
# resize image to multiple of 32, improve SegFormer by 0.5-1.0 mIoU.
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
dict(type='Resize', scale=(2048, 512), keep_ratio=True),
|
||||
# resize image to multiple of 32, improve SegFormer by 0.5-1.0 mIoU.
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
# add loading annotation after ``Resize`` because ground truth
|
||||
# does not need to do resize data transform
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='PackSegInputs')
|
||||
]
|
||||
```
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ class ResizeToMultiple(BaseTransform):
|
|||
if self.interpolation else 'bilinear')
|
||||
|
||||
results['img'] = img
|
||||
results['img_shape'] = img.shape
|
||||
results['pad_shape'] = img.shape
|
||||
results['img_shape'] = img.shape[:2]
|
||||
results['pad_shape'] = img.shape[:2]
|
||||
|
||||
# Align segmentation map to multiple of size divisor.
|
||||
for key in results.get('seg_fields', []):
|
||||
|
|
|
@ -678,4 +678,4 @@ def test_resize_to_multiple():
|
|||
results = transform(results)
|
||||
assert results['img'].shape == (224, 256, 3)
|
||||
assert results['gt_semantic_seg'].shape == (224, 256)
|
||||
assert results['img_shape'] == (224, 256, 3)
|
||||
assert results['img_shape'] == (224, 256)
|
||||
|
|
Loading…
Reference in New Issue