-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
fixed Mask2Former image processor segmentation maps handling #33364
fixed Mask2Former image processor segmentation maps handling #33364
Conversation
5c73b13
to
7aad102
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for working on this and adding tests, just a nit comment
image_mean=0.5, | ||
image_std=0.5, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, revert to the original state :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a revert is applied both values will become 3-element lists and will not be compatible with tests run on images with a different number of channels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to be super precise I can write '[0.5] * num_channels'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that way will be better, just to be sure normalization work for this case 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, added a few comments regarding tests
with pytest.raises(ValueError, match="Unable to infer channel dimension format"): | ||
common(num_channels=5, numpify=True, do_resize=False) | ||
|
||
with pytest.raises(TypeError, match=r"Cannot handle this data type: .*"): | ||
common(num_channels=5, numpify=True, input_data_format=ChannelDimension.LAST) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed this for the first time, we use unittest for testing, can you please update to with self.assertRaises(ValueError)
or assertRaisesRegex
and remove import pytest
on the top of the module.
self.image_processor_tester.num_channels = num_channels | ||
self.image_processor_tester.do_resize = do_resize | ||
self.image_processor_tester.image_mean = [0.5] * num_channels | ||
self.image_processor_tester.image_std = [0.5] * num_channels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it's a good way to modify class properties in place, that may lead to some hard-to-debug issues later. You can recreate an instance here with an updated image processor dict.
common(num_channels=1, numpify=True) | ||
common(num_channels=2, numpify=True, input_data_format=ChannelDimension.LAST) | ||
common(num_channels=5, numpify=True, input_data_format=ChannelDimension.LAST, do_resize=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please make a call with explicit input_data_format=ChannelDimension.FIRST
for better readability of the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing! With @qubvel's suggestions all looks good to me -- let's get his final approval and then we can merge :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
…face#33364) * fixed mask2former image processor segmentation maps handling * introduced review suggestions * introduced review suggestions
Fixes segmentation maps padding size calculation when handling multichannel images using previously inferred
input_data_format
.Fixes #33295
Before submitting
Pull Request section?
to it if that's the case -> Mask2FormerImageProcessor - fails to process multichannel image #33295.
Who can review?
Anyone