Skip to content

Commit

Permalink
[Fix] Fix incorrect img_shape value assignment in RandomCrop (#2469)
Browse files Browse the repository at this point in the history
## Motivation

Fix incorrect `img_shape` value assignment.

## Modification

- mmseg/datasets/transforms/transforms.py
  • Loading branch information
xiexinch authored Jan 10, 2023
1 parent 4e759bb commit f90f7a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mmseg/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ def transform(self, results: dict) -> dict:
# crop semantic seg
for key in results.get('seg_fields', []):
results[key] = self.crop(results[key], crop_bbox)
img_shape = img.shape

results['img'] = img
results['img_shape'] = img_shape
results['img_shape'] = img.shape[:2]
return results

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_datasets/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def test_random_crop():

results = pipeline(results)
assert results['img'].shape[:2] == (h - 20, w - 20)
assert results['img_shape'][:2] == (h - 20, w - 20)
assert results['img_shape'] == (h - 20, w - 20)
assert results['gt_semantic_seg'].shape[:2] == (h - 20, w - 20)


Expand Down

0 comments on commit f90f7a5

Please sign in to comment.