Repository navigation
Fix incorrect bbox_embed initialization when decoder_bbox_embed_share=False in GroundingDINO - #38238
Merged
Cyrilvallez merged 3 commits intoMay 30, 2025
Merged
Conversation
yonigozlan
reviewed
May 21, 2025
yonigozlan
left a comment
Contributor
There was a problem hiding this comment.
Very nice looks ready to merge to me! Could we first get the comments in English though 😉
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
…French to English
Contributor
Author
|
@yonigozlan I've updated the French comments to English as requested. |
Contributor
Author
yonigozlan
approved these changes
May 28, 2025
yonigozlan
left a comment
Contributor
There was a problem hiding this comment.
Great thanks for iterating! LGTM
Contributor
Author
Thanks a lot! Happy to contribute 🙏 |
Cyrilvallez
approved these changes
May 30, 2025
Cyrilvallez
left a comment
Member
There was a problem hiding this comment.
LGTM thanks! Indeed old code did not make sense at all
Contributor
Author
Thanks! Glad the changes make sense now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37333
This PR corrects the initialization of the bbox_embed layers in GroundingDinoForObjectDetection when config.decoder_bbox_embed_share is set to False.
What does this PR do?
Previously, the bbox_embed list was not properly initialized with independent layers when decoder_bbox_embed_share=False. The current implementation mistakenly overwrites the list in each loop iteration, resulting in incorrect behavior.
This PR:
Ensures that a new GroundingDinoMLPPredictionHead is created per decoder layer when decoder_bbox_embed_share=False
Uses nn.ModuleList properly to store separate instances
Preserves shared head behavior when decoder_bbox_embed_share=True
Motivation
Fixing this ensures that each decoder layer has its own bounding box prediction head when specified, which is essential for the expected decoding behavior and model performance.