-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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 PerSAM #23652
Add PerSAM #23652
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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 adding this. If the modification works with all checkpoints for SAM then it passes the test for which we don't require a new model. So in this instance it's fine to add a new config argument to SAM to activate persam mode and adapt the forward, which will also get rid of your warning.
self.layer_norm1 = SamLayerNorm( | ||
self.mask_input_channels, eps=config.layer_norm_eps, data_format="channels_first" | ||
) | ||
self.layer_norm2 = SamLayerNorm( | ||
self.mask_input_channels * 4, eps=config.layer_norm_eps, data_format="channels_first" | ||
) |
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.
@younesbelkada can you confirm if this a mistake in the SAM implementation?
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.
I am unsure if this is needed, @NielsRogge could you elaborate more on why this change is needed? 🙏
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 I had to include this fix to make input_masks
work. I noticed that input_masks
is not tested in tests/models/test_modeling_sam.py
(only input_points
, input_labels
and input_boxes
are).
Might be good to add a test for this
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.
Sounds good to me! Indeed we didn't tested input masks!
Ok, will close this PR in favor of modifying |
What does this PR do?
This PR adds the PerSAM model.
Question: when you do:
you get this warning:
was wondering whether we could suppress this warning. PerSAM uses the exact same weights as the original SAM model, just modifies the forward pass with 2 additional arguments. Currently the model_type is set to "persam" in
PerSamConfig
.