Skip to content

[Fix] Fix ResizeToMultiple transform in MMSeg 1.x #2185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

MengzhangLI
Copy link
Contributor

Motivation

Fix ResizeToMultiple transform in MMSeg 1.x.

Description

In current ResizeToMultiple, it has:

        results['img'] = img
        results['img_shape'] = img.shape
        results['pad_shape'] = img.shape

If dict(type='ResizeToMultiple', size_divisor=32), is added, because in https://github.com/open-mmlab/mmsegmentation/blob/dev-1.x/mmseg/models/utils/wrappers.py#L27, the input and size should have same dimension, but currently it is 2 and 3, respectively. And it would cause error ValueError: size shape must match input shape. Input is 2D, size is 3:

image

Solution

Just modify ResizeToMultiple:

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

image

@codecov
Copy link

codecov bot commented Oct 13, 2022

Codecov Report

Base: 83.53% // Head: 83.55% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (7d4ee84) compared to base (8b39294).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           dev-1.x    #2185      +/-   ##
===========================================
+ Coverage    83.53%   83.55%   +0.02%     
===========================================
  Files          138      138              
  Lines         7790     7790              
  Branches      1167     1167              
===========================================
+ Hits          6507     6509       +2     
+ Misses        1106     1104       -2     
  Partials       177      177              
Flag Coverage Δ
unittests 83.55% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mmseg/datasets/transforms/transforms.py 96.93% <100.00%> (ø)
mmseg/models/backbones/timm_backbone.py 45.83% <0.00%> (+8.33%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@MeowZheng MeowZheng merged commit f3cd44b into open-mmlab:dev-1.x Oct 14, 2022
@MeowZheng MeowZheng added the 1.x Related issue of 1.x version label Oct 18, 2022
MeowZheng pushed a commit to MeowZheng/mmsegmentation that referenced this pull request Nov 1, 2022
@ThorPham
Copy link

ThorPham commented Nov 8, 2022

I has same error like this when i train customer dataset. But i can't fix with modify
results['img'] = img results['img_shape'] = img.shape[:2] results['pad_shape'] = img.shape[:2]
I printed function resize in wrappers.py
I don't know why the last is shape Size([512, 512, 3])
image

Here is log error
image

@MengzhangLI MengzhangLI deleted the fix_resize_to_multiple branch November 22, 2022 15:21
nahidnazifi87 pushed a commit to nahidnazifi87/mmsegmentation_playground that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x Related issue of 1.x version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants