Skip to content

[prototype] The new Transforms API should support different fill values for Segmentation masks than Images #6568

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

Closed
3 tasks
datumbox opened this issue Sep 12, 2022 · 1 comment

Comments

@datumbox
Copy link
Contributor

datumbox commented Sep 12, 2022

🚀 The feature

While migrating the reference scripts for Segmentation to the latest API, @pmeier noticed that one of the transforms uses a different fill value for Images vs Segmentation masks:

image = pad_if_smaller(image, self.size)
target = pad_if_smaller(target, self.size, fill=255)

The 255 value is used to encode values that the loss should ignore:

losses[name] = nn.functional.cross_entropy(x, target, ignore_index=255)

This means that we should have different fill values for Images and Segmentation masks. Other libraries such as fvcore already do this by adding separate fill pad_value and seg_pad_value parameters.

It's worth noting that a parameter behaving similarly is interpolation only that in the case of masks it's fixed to nearest and thus it's not necessary to have 2 of them.

Motivation, pitch

Here is what needs to be done:

  • All eligible kernels (affine, rotate, pad, perspective, elastic, etc) that could receive a fill parameter should receive it for for SegmentationMask
  • Make it possible for all related Transforms (Pad, RandomZoomOut, RandomRotation, RandomAffine, ElasticTransform, FixedSizeCrop, etc) to receive different parameters for Image and Masks.
  • Update the tests.

Alternatives

No response

Additional context

No response

cc @vfdev-5 @bjuncek @pmeier

@vfdev-5
Copy link
Collaborator

vfdev-5 commented Sep 26, 2022

Done in #6599 and #6586

@vfdev-5 vfdev-5 closed this as completed Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants