- Notifications
You must be signed in to change notification settings - Fork2.8k
[Fix] Fix dimension error when using slide inference with Mask2Former head#3752
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
Joris-Kuehl-TU-Berlin wants to merge1 commit intoopen-mmlab:dev-1.xChoose a base branch fromJoris-Kuehl-TU-Berlin:make-mask2former-slide-compatible
base:dev-1.x
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Open
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Motivation
The method
predictinmmseg/models/decode_heads/mask2former_head.py is incompatible with the'slide'inference mode.To elaborate, on line 280 of
slide_inferenceinmmseg/models/segmentors/encoder_decoder.py, the key'img_shape'ofbatch_img_metas[0]is overwritten by the shape of the cropped image / sliding window.In line 353 ofmmseg/models/decode_heads/decode_head.py, this is the first key that is used to get the target size for upsampling. As such,
crop_seg_logitswill have the same shape ascrop_img.Inmmseg/models/decode_heads/mask2former_head.py, the first shape that is referenced as a target for upsampling is
'pad_shape'instead. Sinceslide_inferencedoes not overwrite this key, each cropped image is upsampled to the size of the full image, and then further padded with zeros byslide_inference, leading to a dimension mismatch when trying to add up the paddedcrop_seg_logits. This leads to the issue described in#3666.Modification
I have simply adjusted the size selection inmmseg/models/decode_heads/mask2former_head.py to match that ofmmseg/models/decode_heads/decode_head.py. As a result, a dimension mismatch no longer occurs when using slide inference with a Mask2Former head.
Checklist