DINOv2 register support
What does this PR do?
This PR adds DINOv2 with registers as proposed in Vision Transformers Need Registers.
My aim was to add registers with minimal code changes in a backward compatible way.
My changes were made using the facebookresearch/dinov2 repository commits.
I also had to add additional options for interpolation which caused me to comment and fix the intepolate embeddings method. (Said comments were written on the fly as I was understanding and changing the code and are biased, and can be removed).
While doing that I added support for non square patch sizes which seamed like a bug since Dinov2PatchEmbeddings supported them, but the rest of the code didn't.
To do:
Fixes https://github.com/huggingface/transformers/issues/27379 Alternatives https://github.com/huggingface/transformers/pull/31832
Before submitting
- [ ] Did you read the contributor guideline, Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the forum? Please add a link to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
- [ ] Did you write any new necessary tests?
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.