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 Flax Dinov2 #31960

Merged
merged 52 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
cee4cf8
tfmsenv restored in main
MHRDYN7 Jul 4, 2024
7782a52
installed flax
MHRDYN7 Jul 9, 2024
ee04716
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Jul 10, 2024
53b4f36
forward pass done and all tests passed
MHRDYN7 Jul 14, 2024
6505d5c
Merge branch 'add_FlaxDinov2' of https://github.com/MHRDYN7/transform…
MHRDYN7 Jul 14, 2024
aacfc65
make fix-copies and cleaning the scripts
MHRDYN7 Jul 14, 2024
d9e93f8
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Jul 23, 2024
94857a2
fixup attempt 1
MHRDYN7 Jul 23, 2024
a53426d
fixup attempt 2
MHRDYN7 Jul 23, 2024
c805f2e
fixup third attempt
MHRDYN7 Jul 23, 2024
518f4ba
fixup attempt 4
MHRDYN7 Jul 24, 2024
44ec67b
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Jul 24, 2024
f957993
fixup attempt 5
MHRDYN7 Jul 24, 2024
60666b3
dinov2 doc fixed
MHRDYN7 Jul 26, 2024
d985288
FlaxDinov2Model + ForImageClassification added to OBJECTS_TO_IGNORE
MHRDYN7 Jul 26, 2024
0750b05
external pos_encoding layer removed
MHRDYN7 Jul 27, 2024
50278a1
fixup attempt 6
MHRDYN7 Jul 27, 2024
4b1c4c8
fixed integration test values
MHRDYN7 Jul 27, 2024
5d23c13
fixup attempt 7
MHRDYN7 Jul 27, 2024
f10d90b
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Jul 27, 2024
20fd4c9
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
85ca2c8
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
2ac2cd9
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
5289431
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
a22400b
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
f731e4e
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
df33e8a
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
0ecb949
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
3a3944d
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
7b2ebb6
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
77d5a7d
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
8c1439b
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
0201b03
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
7c627a9
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
f58b9b3
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
6634d03
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 1, 2024
c0a20e6
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Aug 1, 2024
9cedc0f
comments removed
MHRDYN7 Aug 1, 2024
1372ec7
comment removed from the test
MHRDYN7 Aug 1, 2024
a87235d
fixup
MHRDYN7 Aug 1, 2024
305b6db
Update src/transformers/models/dinov2/modeling_flax_dinov2.py
MHRDYN7 Aug 2, 2024
0606e67
new fixes 1
MHRDYN7 Aug 2, 2024
b543a6d
interpolate_pos_encoding function removed
MHRDYN7 Aug 2, 2024
0056b6f
droppath rng fixed, pretrained beit copied-from still not working
MHRDYN7 Aug 2, 2024
1f954ee
modeling_flax_dinov2.py reformatted
MHRDYN7 Aug 2, 2024
86f619f
Update tests/models/dinov2/test_modeling_flax_dinov2.py
MHRDYN7 Aug 2, 2024
5a9eb9e
added Copied from, to the tests
MHRDYN7 Aug 2, 2024
373850d
copied from statements removed from tests
MHRDYN7 Aug 2, 2024
3b04809
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Aug 4, 2024
6772dd7
fixed copied from statements in the tests
MHRDYN7 Aug 4, 2024
1603d56
Merge branch 'huggingface:main' into add_FlaxDinov2
MHRDYN7 Aug 16, 2024
e92ea55
[run_slow] dinov2
MHRDYN7 Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Flax), PyTorch, and/or TensorFlow.
| [DETR](model_doc/detr) | ✅ | ❌ | ❌ |
| [DialoGPT](model_doc/dialogpt) | ✅ | ✅ | ✅ |
| [DiNAT](model_doc/dinat) | ✅ | ❌ | ❌ |
| [DINOv2](model_doc/dinov2) | ✅ | ❌ | |
| [DINOv2](model_doc/dinov2) | ✅ | ❌ | |
| [DistilBERT](model_doc/distilbert) | ✅ | ✅ | ✅ |
| [DiT](model_doc/dit) | ✅ | ❌ | ✅ |
| [DonutSwin](model_doc/donut) | ✅ | ❌ | ❌ |
Expand Down
20 changes: 20 additions & 0 deletions docs/source/en/model_doc/dinov2.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ If you're interested in submitting a resource to be included here, please feel f

[[autodoc]] Dinov2Config

<frameworkcontent>
<pt>

## Dinov2Model

[[autodoc]] Dinov2Model
Expand All @@ -81,3 +84,20 @@ If you're interested in submitting a resource to be included here, please feel f

[[autodoc]] Dinov2ForImageClassification
- forward

</pt>
<jax>

## FlaxDinov2Model

[[autodoc]] FlaxDinov2Model
- __call__


## FlaxDinov2ForImageClassification

[[autodoc]] FlaxDinov2ForImageClassification
- __call__

</jax>
</frameworkcontent>
12 changes: 12 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4542,6 +4542,13 @@
"FlaxCLIPVisionPreTrainedModel",
]
)
_import_structure["models.dinov2"].extend(
[
"FlaxDinov2Model",
"FlaxDinov2ForImageClassification",
"FlaxDinov2PreTrainedModel",
]
)
_import_structure["models.distilbert"].extend(
[
"FlaxDistilBertForMaskedLM",
Expand Down Expand Up @@ -8624,6 +8631,11 @@
FlaxCLIPVisionModel,
FlaxCLIPVisionPreTrainedModel,
)
from .models.dinov2 import (
FlaxDinov2ForImageClassification,
FlaxDinov2Model,
FlaxDinov2PreTrainedModel,
)
from .models.distilbert import (
FlaxDistilBertForMaskedLM,
FlaxDistilBertForMultipleChoice,
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/modeling_flax_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
("blenderbot-small", "FlaxBlenderbotSmallModel"),
("bloom", "FlaxBloomModel"),
("clip", "FlaxCLIPModel"),
("dinov2", "FlaxDinov2Model"),
("distilbert", "FlaxDistilBertModel"),
("electra", "FlaxElectraModel"),
("gemma", "FlaxGemmaModel"),
Expand Down Expand Up @@ -124,6 +125,7 @@
[
# Model for Image-classsification
("beit", "FlaxBeitForImageClassification"),
("dinov2", "FlaxDinov2ForImageClassification"),
("regnet", "FlaxRegNetForImageClassification"),
("resnet", "FlaxResNetForImageClassification"),
("vit", "FlaxViTForImageClassification"),
Expand Down
25 changes: 25 additions & 0 deletions src/transformers/models/dinov2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_flax_available,
is_torch_available,
)

Expand All @@ -35,6 +36,18 @@
"Dinov2Backbone",
]

try:
if not is_flax_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_flax_dinov2"] = [
"FlaxDinov2ForImageClassification",
"FlaxDinov2Model",
"FlaxDinov2PreTrainedModel",
]

if TYPE_CHECKING:
from .configuration_dinov2 import Dinov2Config, Dinov2OnnxConfig

Expand All @@ -51,6 +64,18 @@
Dinov2PreTrainedModel,
)

try:
if not is_flax_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_flax_dinov2 import (
FlaxDinov2ForImageClassification,
FlaxDinov2Model,
FlaxDinov2PreTrainedModel,
)

else:
import sys

Expand Down
Loading