-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
8267 fix normalize intensity #8286
base: dev
Are you sure you want to change the base?
Conversation
Fix channel-wise intensity normalization for integer type inputs. Signed-off-by: Adrian Voicu <[email protected]>
Fix channel-wise intensity normalization for integer type inputs. Signed-off-by: Adrian Voicu <[email protected]>
I, advcu987 <[email protected]>, hereby add my Signed-off-by to this commit: b55a02e I, advcu987 <[email protected]>, hereby add my Signed-off-by to this commit: 28a0df1 I, advcu987 <[email protected]>, hereby add my Signed-off-by to this commit: bdb3604 Signed-off-by: advcu987 <[email protected]>
@@ -907,6 +907,8 @@ def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: | |||
if self.divisor is not None and len(self.divisor) != len(img): | |||
raise ValueError(f"img has {len(img)} channels, but divisor has {len(self.divisor)} components.") | |||
|
|||
img, *_ = convert_data_type(img, dtype=torch.float32) |
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 fix. Seems we can remove the convert out side of the self._normalize
to avoid convert multiple times here.
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.
Should we also check that the dtype of img
isn't float16/float32/float64 and only do the conversion in that 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.
Yes, it would be a little more rigorous. Although in the non channel-wise version, we do the conversion directly. But yes if we could do the check, would be better.
Fixes #8267 .
Description
Fix channel-wise intensity normalization for integer type inputs.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.