-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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 DAB-DETR Object detection/segmentation model #30803
base: main
Are you sure you want to change the base?
Add DAB-DETR Object detection/segmentation model #30803
Conversation
Hi @conditionedstimulus, thanks for opening a PR! Just skimming over the modeling files, it looks like all of the modules are copied from, or can be copied from conditional DETR. Are there any architectural changes this model brings? If not, then all we need to do is convert the checkpoints and upload those to the hub such that they can be loaded in ConditionalDETR directly |
Hi Amy, I attached a photo comparing the cross-attention of the decoder in DETR, Conditional DETR, and DAB DETR, as this is the main architectural difference. I copied the code from Conditional DETR because this model is an extension/evolved version of Conditional DETR. I believe it would be cool and useful to include this model in the HF object detection collection. |
@conditionedstimulus Thanks for sharing! OK, seems useful to have this available as an option as part of the DETR family in the library. Feel free to ping me when the PR is ready for review. cc @qubvel for reference |
btw, I see there is a "DAB-Deformable-DETR-R50-v2" checkpoint on github which has the best metrics, is it possible to convert it as well? |
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.
Tested inference and training as well, all goes smoothly:
- https://github.com/qubvel/transformers-notebooks/blob/main/notebooks/DAB_DETR_fintune_on_a_custom_dataset.ipynb
- https://github.com/qubvel/transformers-notebooks/blob/main/notebooks/DAB_DETR_inference.ipynb
Final steps to merge the model:
- Merge/rebase on
main
- Run slow tests (I can trigger it, as soon as
main
merged) -
Convert the last checkpoint, mentioned above - Add model cards for all checkpoints on the Hub
- Transfer checkpoints to IDEA-Research org (also on my side, only if it's ok with you) + correct checkpoint's path in code
- Merge!
Thank you, @conditionedstimulus, for the iterations, and apologize for the delays on our end. 🤗
Hi @qubvel, Thank you for your feedback and review! Here's an update on my progress:
Model cards: If you would like any modifications to the model cards, please let me know! |
run-slow: dab_detr |
This comment contains run-slow, running the specified jobs: ['models/dab_detr'] ... |
I see these 3 tests are failing on CI:
Did they pass locally? |
Also it seems like images are not loading in model cards (maybe my issue only). Feel free to open a upload them into dataset with "Add file" button and ping me to merge. |
Hi @qubvel, I opened the PR on huggingface datasets. Thank you! |
Thanks, merged! Yeah, integration tests will be fixed as soon as we transfer checkpoints. |
Thanks! No i run actually on a really weak cpu only with 8gb ram (i5 dual core) |
I think that's the reason, the test is just skipped for cpu-only env. Try to run with |
Hi @qubvel , This test fails: FAILED tests/models/qwen2_5_vl/test_modeling_qwen2_5_vl.py::Qwen2_5_VLModelTest::test_generate_from_inputs_embeds_1_beam_search Thanks! |
module.class_embed.bias.data = ( | ||
torch.ones( | ||
self.config.num_labels, | ||
device=module.class_embed.bias.data.device, | ||
dtype=module.class_embed.bias.data.dtype, | ||
) | ||
* bias_value | ||
) |
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 suppose we can use module.class_embed.bias.data.fill_(bias_value)
or smth similar
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, better solution. I've just updated the code.
run-slow: dab_detr |
This comment contains run-slow, running the specified jobs: ['models/dab_detr'] ... |
run-slow: dab_detr |
@qubvel I can see my comment doesn't have the superpower to trigger the bot to run the tests from a comment. :) |
Yeah, it's available for maintainers only 😄 |
run-slow: dab_detr |
This comment contains run-slow, running the specified jobs: ['models/dab_detr'] ... |
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 fixing tests! While I asking the team to move checkpoints to the org, can you please update the last thing (I hope 😄)
self.assertEqual(len(results["scores"]), 5) | ||
self.assertTrue(torch.allclose(results["scores"], expected_scores, atol=1e-4)) | ||
self.assertSequenceEqual(results["labels"].tolist(), expected_labels) | ||
self.assertTrue(torch.allclose(results["boxes"][0, :], expected_boxes, atol=1e-4)) |
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 hope the last thing! Can you please update to use torch.testing.assert_close
instead of self.assertTrue(torch.allclose(...
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.
Here and in other places in tests, for example:
https://github.com/huggingface/transformers/pull/35903/files
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.
Hi, no problem I changed and ran the test w my model source. Is it enough to change only in that part of the tests or it should be in the whole file? Also apprx. how much time it's gonna take to move the model cards?:)
thanks
What does this PR do?
Add DAB-DETR Object detection model. Paper: https://arxiv.org/abs/2201.12329
Original code repo: https://github.com/IDEA-Research/DAB-DETR
Fixes # (issue)
[WIP] This model is part of how DETR models have evolved, alongside DN DETR (not part of this PR), to pave the way for newer and better models like Dino and Stable Dino in object detection
Who can review?
@amyeroberts