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

Add support of segmentation mask in RandomCutout #2004

Merged

Conversation

cosmo3769
Copy link
Contributor

@cosmo3769 cosmo3769 commented Aug 2, 2023

What does this PR do?

Related: #1992

Add support of segmentation mask in Augmix layer. Here is the colab link for demo.

Output generated by demo:

Screenshot 2023-08-18 at 4 45 51 AM

Who can review?

@ianstenbit @jbischof

@cosmo3769 cosmo3769 force-pushed the randomcutout-segmentation-mask branch from 69e6422 to 0f5e539 Compare August 2, 2023 02:27
@ianstenbit
Copy link
Contributor

ianstenbit commented Aug 2, 2023

Thanks for the PR!

I think we need to think a bit about how to handle segmentation masks in this case.
For example, in GridMask, we actually keep the full segmentation mask unedited as the ground-truth label. It may be that this is also the best approach here.

My concern with zeroing-out the mask is that we're effectively telling the model that this is neither foreground class nor background class. Maybe that's okay, but I don't have a great intuition for that.

It could be ideal to instead set the masked-out area to have the background class, but that introduces some API awkwardness as the caller needs to specify what the background class is.

My intuition is that the best approach is probably to leave the seg mask unmodified, but it's hard to say for sure.

I'd propose that we test each option with my (WIP) KerasCV segmentation guide and see which one yields the best results

@cosmo3769
Copy link
Contributor Author

cosmo3769 commented Aug 3, 2023

Hey @ianstenbit,

Thank you for this intuition and your colab notebook. I will test out all the possibilities and see which one yields the best results.
Also, I have been creating one colab where I was testing all these layers. I was thinking of making it backend agnostic, testing all the layers and publishing a report in keras.io. 😄

@cosmo3769
Copy link
Contributor Author

cosmo3769 commented Aug 17, 2023

Hey @ianstenbit, I have tested it and I find out that it works best when we don't apply random cutout to mask. Here is the colab link.

  • With RandomCutout applied to mask - 80.75% test accuracy.
  • With RandomCutout not applied to mask - 83.89% test accuracy.

I have updated the code to remove randomcutout from mask.

@ianstenbit
Copy link
Contributor

Hey @ianstenbit, I have tested it and I find out that it works best when we don't apply random cutout to mask. Here is the colab link.

  • With RandomCutout applied to mask - 80.75% test accuracy.
  • With RandomCutout not applied to mask - 83.89% test accuracy.

I have updated the code to remove randomcutout from mask.

Awesome thank you for doing this test -- that's awesome!

@ianstenbit
Copy link
Contributor

/gcbrun

Copy link
Contributor

@ianstenbit ianstenbit left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@ianstenbit
Copy link
Contributor

/gcbrun

@ianstenbit ianstenbit merged commit d01aee4 into keras-team:master Aug 22, 2023
9 checks passed
@cosmo3769 cosmo3769 deleted the randomcutout-segmentation-mask branch September 11, 2023 11:27
ghost pushed a commit to y-vectorfield/keras-cv that referenced this pull request Nov 16, 2023
* added support of segmentation-mask

* added demo

* add test

* update readme

* random cutout removed from mask

* update test
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.

None yet

2 participants