Skip to content
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

Fix downscaling and data type of segmentation masks #29

Merged
merged 4 commits into from
Mar 20, 2024

Conversation

uermel
Copy link
Contributor

@uermel uermel commented Mar 19, 2024

After the initial comparison with the label the maps are already binary, so after the scaling operation we need to compare with 1 instead of comparing with the label again.

Scaled masks are binary and should be stored as int8.

This PR fixes that.

@uermel uermel requested a review from manasaV3 March 19, 2024 23:13
@uermel uermel changed the title Fix the downscaling of segmentation masks Fix downscaling and data type of segmentation masks Mar 19, 2024
@@ -148,7 +148,7 @@ def make_pyramid(self, max_layers: int = 2, scale_z_axis: bool = True) -> List[n

# For semantic segmentation masks we want to have a binary output.
# downscale_local_mean will return float array even for bool input with non-binary values
scaled = (downscale_local_mean(pyramid[i] == self.label, (z_scale, 2, 2)) > 0).astype(np.float32)
scaled = (downscale_local_mean(pyramid[i] == 1, (z_scale, 2, 2)) > 0).astype(np.int8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be just be pyramid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.

@uermel uermel requested a review from manasaV3 March 20, 2024 00:04
@uermel uermel merged commit 13b09cb into main Mar 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants