Equimo 0.1.3a8__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. equimo-0.2.0/Equimo.egg-info/PKG-INFO +167 -0
  2. {equimo-0.1.3a8 → equimo-0.2.0}/Equimo.egg-info/SOURCES.txt +6 -1
  3. equimo-0.2.0/Equimo.egg-info/requires.txt +10 -0
  4. equimo-0.2.0/PKG-INFO +167 -0
  5. equimo-0.2.0/README.md +151 -0
  6. equimo-0.2.0/equimo/converters/__init__.py +1 -0
  7. equimo-0.2.0/equimo/converters/dinov2.py +69 -0
  8. equimo-0.2.0/equimo/converters/utils.py +152 -0
  9. equimo-0.2.0/equimo/io.py +216 -0
  10. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/attention.py +114 -94
  11. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/convolution.py +2 -2
  12. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/dropout.py +4 -93
  13. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/ffn.py +21 -20
  14. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/generic.py +5 -3
  15. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/mamba.py +2 -2
  16. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/patch.py +5 -3
  17. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/sharing.py +5 -5
  18. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/fastervit.py +15 -15
  19. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/mlla.py +7 -7
  20. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/partialformer.py +19 -22
  21. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/shvit.py +20 -20
  22. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/vit.py +24 -58
  23. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/vssd.py +7 -7
  24. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/utils.py +0 -1
  25. {equimo-0.1.3a8 → equimo-0.2.0}/pyproject.toml +17 -1
  26. equimo-0.2.0/tests/test_models.py +122 -0
  27. equimo-0.1.3a8/Equimo.egg-info/PKG-INFO +0 -104
  28. equimo-0.1.3a8/Equimo.egg-info/requires.txt +0 -4
  29. equimo-0.1.3a8/PKG-INFO +0 -104
  30. equimo-0.1.3a8/README.md +0 -92
  31. {equimo-0.1.3a8 → equimo-0.2.0}/Equimo.egg-info/dependency_links.txt +0 -0
  32. {equimo-0.1.3a8 → equimo-0.2.0}/Equimo.egg-info/top_level.txt +0 -0
  33. {equimo-0.1.3a8 → equimo-0.2.0}/LICENSE.md +0 -0
  34. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/__init__.py +0 -0
  35. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/__init__.py +0 -0
  36. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/downsample.py +0 -0
  37. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/norm.py +0 -0
  38. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/posemb.py +0 -0
  39. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/layers/squeeze_excite.py +0 -0
  40. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/__init__.py +0 -0
  41. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/models/emamodel.py +0 -0
  42. {equimo-0.1.3a8 → equimo-0.2.0}/equimo/ops/scan.py +0 -0
  43. {equimo-0.1.3a8 → equimo-0.2.0}/setup.cfg +0 -0
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.2
2
+ Name: Equimo
3
+ Version: 0.2.0
4
+ Summary: Implementation of popular vision models in Jax
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: einops>=0.8.0
8
+ Requires-Dist: equinox>=0.11.5
9
+ Requires-Dist: jax>=0.4.25
10
+ Requires-Dist: jaxlib>=0.4.25
11
+ Requires-Dist: loguru>=0.7.3
12
+ Requires-Dist: lz4>=4.4.3
13
+ Requires-Dist: requests>=2.32.3
14
+ Provides-Extra: torch
15
+ Requires-Dist: torch>=2.6.0; extra == "torch"
16
+
17
+ # Equimo: Modern Vision Models in JAX/Equinox
18
+
19
+ **WARNING**: This is a research library implementing recent computer vision models. The implementations are based on paper descriptions and may not be exact replicas of the original implementations. Use with caution in production environments.
20
+
21
+ Equimo (Equinox Image Models) provides JAX/Equinox implementations of recent computer vision models, currently focusing (but not limited to) on transformer and state-space architectures.
22
+
23
+ ## Features
24
+
25
+ - Pure JAX/Equinox implementations
26
+ - Focus on recent architectures (2023-2024 papers)
27
+ - Modular design for easy experimentation
28
+ - Extensive documentation and type hints
29
+
30
+ ## Installation
31
+
32
+ ### From PyPI
33
+
34
+ ```bash
35
+ pip install equimo
36
+ ```
37
+
38
+ ### From Source
39
+
40
+ ```bash
41
+ git clone https://github.com/clementpoiret/equimo.git
42
+ cd equimo
43
+ pip install -e .
44
+ ```
45
+
46
+ ## Implemented Models
47
+
48
+ | Model | Paper | Year | Status |
49
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | --------- |
50
+ | FasterViT | [FasterViT: Fast Vision Transformers with Hierarchical Attention](https://arxiv.org/abs/2306.06189) | 2023 | ✅ |
51
+ | Castling-ViT | [Castling-ViT: Compressing Self-Attention via Switching Towards Linear-Angular Attention During Vision Transformer Inference](https://arxiv.org/abs/2211.10526) | 2023 | Partial\* |
52
+ | MLLA | [Mamba-like Linear Attention](https://arxiv.org/abs/2405.16605) | 2024 | ✅ |
53
+ | PartialFormer | [Efficient Vision Transformers with Partial Attention](https://eccv.ecva.net/virtual/2024/poster/1877) | 2024 | ✅ |
54
+ | SHViT | [SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design](https://arxiv.org/abs/2401.16456) | 2024 | ✅ |
55
+ | VSSD | [VSSD: Vision Mamba with Non-Causal State Space Duality](https://arxiv.org/abs/2407.18559) | 2024 | ✅ |
56
+
57
+ \*: Only contains the [Linear Angular Attention](https://github.com/clementpoiret/Equimo/blob/f8fcc79e45ca65e9deb1d970c4286c0b8562f9c2/equimo/layers/attention.py#L1407) module. It is straight forward to build a ViT around it, but may require an additional `__call__` kwarg to control the `sparse_reg` bool.
58
+
59
+ ## Basic Usage
60
+
61
+ ```python
62
+ import jax
63
+
64
+ import equimo.models as em
65
+
66
+ # Create a model (e.g. `faster_vit_0_224`)
67
+ key = jax.random.PRNGKey(0)
68
+ model = em.FasterViT(
69
+ img_size=224,
70
+ in_channels=3,
71
+ dim=64,
72
+ in_dim=64,
73
+ depths=[2, 3, 6, 5],
74
+ num_heads=[2, 4, 8, 16],
75
+ hat=[False, False, True, False],
76
+ window_size=[7, 7, 7, 7],
77
+ ct_size=2,
78
+ key=key,
79
+ )
80
+
81
+ # Generate random input
82
+ x = jax.random.normal(key, (3, 224, 224))
83
+
84
+ # Run inference
85
+ output = model(x, enable_dropout=False, key=key)
86
+ ```
87
+
88
+ ## Saving and Loading Models
89
+
90
+ Equimo provides utilities for saving models locally and loading pre-trained models from the
91
+ [official repository](https://huggingface.co/poiretclement/equimo).
92
+
93
+ ### Saving Models Locally
94
+
95
+ ```python
96
+ from pathlib import Path
97
+ from equimo.io import save_model
98
+
99
+ # Save model with compression (creates .tar.lz4 file)
100
+ save_model(
101
+ Path("path/to/save/model"),
102
+ model, # can be any model you created using Equimo
103
+ model_config,
104
+ torch_hub_cfg, # This can be an empty list, it's mainly to keep track of where are the weights coming
105
+ compression=True
106
+ )
107
+
108
+ # Save model without compression (creates directory)
109
+ save_model(
110
+ Path("path/to/save/model"),
111
+ model,
112
+ model_config,
113
+ torch_hub_cfg,
114
+ compression=False
115
+ )
116
+ ```
117
+
118
+ ### Loading Models
119
+
120
+ ```python
121
+ from equimo.io import load_model
122
+
123
+ # Load a pre-trained model from the official repository
124
+ model = load_model(cls="vit", identifier="dinov2_vits14_reg")
125
+
126
+ # Load a local model (compressed)
127
+ model = load_model(cls="vit", path=Path("path/to/model.tar.lz4"))
128
+
129
+ # Load a local model (uncompressed directory)
130
+ model = load_model(cls="vit", path=Path("path/to/model/"))
131
+ ```
132
+
133
+ #### List of pretrained models
134
+
135
+ Currently, only [DinoV2](https://github.com/facebookresearch/dinov2/) have been ported, therefore the following
136
+ identifiers are available:
137
+
138
+ - `dinov2_vitb14.tar.lz4`
139
+ - `dinov2_vitb14_reg.tar.lz4`
140
+ - `dinov2_vitl14.tar.lz4`
141
+ - `dinov2_vitl14_reg.tar.lz4`
142
+ - `dinov2_vits14.tar.lz4`
143
+ - `dinov2_vits14_reg.tar.lz4`
144
+
145
+ (`giant` version coming soon)
146
+
147
+ ## Contributing
148
+
149
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
150
+
151
+ ## License
152
+
153
+ This project is licensed under the MIT License - see the LICENSE file for details.
154
+
155
+ ## Citation
156
+
157
+ If you use Equimo in your research, please cite:
158
+
159
+ ```bibtex
160
+ @software{equimo2024,
161
+ author = {Clément POIRET},
162
+ title = {Equimo: Modern Vision Models in JAX/Equinox},
163
+ year = {2024},
164
+ publisher = {GitHub},
165
+ url = {https://github.com/clementpoiret/equimo}
166
+ }
167
+ ```
@@ -7,7 +7,11 @@ Equimo.egg-info/dependency_links.txt
7
7
  Equimo.egg-info/requires.txt
8
8
  Equimo.egg-info/top_level.txt
9
9
  equimo/__init__.py
10
+ equimo/io.py
10
11
  equimo/utils.py
12
+ equimo/converters/__init__.py
13
+ equimo/converters/dinov2.py
14
+ equimo/converters/utils.py
11
15
  equimo/layers/__init__.py
12
16
  equimo/layers/attention.py
13
17
  equimo/layers/convolution.py
@@ -29,4 +33,5 @@ equimo/models/partialformer.py
29
33
  equimo/models/shvit.py
30
34
  equimo/models/vit.py
31
35
  equimo/models/vssd.py
32
- equimo/ops/scan.py
36
+ equimo/ops/scan.py
37
+ tests/test_models.py
@@ -0,0 +1,10 @@
1
+ einops>=0.8.0
2
+ equinox>=0.11.5
3
+ jax>=0.4.25
4
+ jaxlib>=0.4.25
5
+ loguru>=0.7.3
6
+ lz4>=4.4.3
7
+ requests>=2.32.3
8
+
9
+ [torch]
10
+ torch>=2.6.0
equimo-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.2
2
+ Name: Equimo
3
+ Version: 0.2.0
4
+ Summary: Implementation of popular vision models in Jax
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: einops>=0.8.0
8
+ Requires-Dist: equinox>=0.11.5
9
+ Requires-Dist: jax>=0.4.25
10
+ Requires-Dist: jaxlib>=0.4.25
11
+ Requires-Dist: loguru>=0.7.3
12
+ Requires-Dist: lz4>=4.4.3
13
+ Requires-Dist: requests>=2.32.3
14
+ Provides-Extra: torch
15
+ Requires-Dist: torch>=2.6.0; extra == "torch"
16
+
17
+ # Equimo: Modern Vision Models in JAX/Equinox
18
+
19
+ **WARNING**: This is a research library implementing recent computer vision models. The implementations are based on paper descriptions and may not be exact replicas of the original implementations. Use with caution in production environments.
20
+
21
+ Equimo (Equinox Image Models) provides JAX/Equinox implementations of recent computer vision models, currently focusing (but not limited to) on transformer and state-space architectures.
22
+
23
+ ## Features
24
+
25
+ - Pure JAX/Equinox implementations
26
+ - Focus on recent architectures (2023-2024 papers)
27
+ - Modular design for easy experimentation
28
+ - Extensive documentation and type hints
29
+
30
+ ## Installation
31
+
32
+ ### From PyPI
33
+
34
+ ```bash
35
+ pip install equimo
36
+ ```
37
+
38
+ ### From Source
39
+
40
+ ```bash
41
+ git clone https://github.com/clementpoiret/equimo.git
42
+ cd equimo
43
+ pip install -e .
44
+ ```
45
+
46
+ ## Implemented Models
47
+
48
+ | Model | Paper | Year | Status |
49
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | --------- |
50
+ | FasterViT | [FasterViT: Fast Vision Transformers with Hierarchical Attention](https://arxiv.org/abs/2306.06189) | 2023 | ✅ |
51
+ | Castling-ViT | [Castling-ViT: Compressing Self-Attention via Switching Towards Linear-Angular Attention During Vision Transformer Inference](https://arxiv.org/abs/2211.10526) | 2023 | Partial\* |
52
+ | MLLA | [Mamba-like Linear Attention](https://arxiv.org/abs/2405.16605) | 2024 | ✅ |
53
+ | PartialFormer | [Efficient Vision Transformers with Partial Attention](https://eccv.ecva.net/virtual/2024/poster/1877) | 2024 | ✅ |
54
+ | SHViT | [SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design](https://arxiv.org/abs/2401.16456) | 2024 | ✅ |
55
+ | VSSD | [VSSD: Vision Mamba with Non-Causal State Space Duality](https://arxiv.org/abs/2407.18559) | 2024 | ✅ |
56
+
57
+ \*: Only contains the [Linear Angular Attention](https://github.com/clementpoiret/Equimo/blob/f8fcc79e45ca65e9deb1d970c4286c0b8562f9c2/equimo/layers/attention.py#L1407) module. It is straight forward to build a ViT around it, but may require an additional `__call__` kwarg to control the `sparse_reg` bool.
58
+
59
+ ## Basic Usage
60
+
61
+ ```python
62
+ import jax
63
+
64
+ import equimo.models as em
65
+
66
+ # Create a model (e.g. `faster_vit_0_224`)
67
+ key = jax.random.PRNGKey(0)
68
+ model = em.FasterViT(
69
+ img_size=224,
70
+ in_channels=3,
71
+ dim=64,
72
+ in_dim=64,
73
+ depths=[2, 3, 6, 5],
74
+ num_heads=[2, 4, 8, 16],
75
+ hat=[False, False, True, False],
76
+ window_size=[7, 7, 7, 7],
77
+ ct_size=2,
78
+ key=key,
79
+ )
80
+
81
+ # Generate random input
82
+ x = jax.random.normal(key, (3, 224, 224))
83
+
84
+ # Run inference
85
+ output = model(x, enable_dropout=False, key=key)
86
+ ```
87
+
88
+ ## Saving and Loading Models
89
+
90
+ Equimo provides utilities for saving models locally and loading pre-trained models from the
91
+ [official repository](https://huggingface.co/poiretclement/equimo).
92
+
93
+ ### Saving Models Locally
94
+
95
+ ```python
96
+ from pathlib import Path
97
+ from equimo.io import save_model
98
+
99
+ # Save model with compression (creates .tar.lz4 file)
100
+ save_model(
101
+ Path("path/to/save/model"),
102
+ model, # can be any model you created using Equimo
103
+ model_config,
104
+ torch_hub_cfg, # This can be an empty list, it's mainly to keep track of where are the weights coming
105
+ compression=True
106
+ )
107
+
108
+ # Save model without compression (creates directory)
109
+ save_model(
110
+ Path("path/to/save/model"),
111
+ model,
112
+ model_config,
113
+ torch_hub_cfg,
114
+ compression=False
115
+ )
116
+ ```
117
+
118
+ ### Loading Models
119
+
120
+ ```python
121
+ from equimo.io import load_model
122
+
123
+ # Load a pre-trained model from the official repository
124
+ model = load_model(cls="vit", identifier="dinov2_vits14_reg")
125
+
126
+ # Load a local model (compressed)
127
+ model = load_model(cls="vit", path=Path("path/to/model.tar.lz4"))
128
+
129
+ # Load a local model (uncompressed directory)
130
+ model = load_model(cls="vit", path=Path("path/to/model/"))
131
+ ```
132
+
133
+ #### List of pretrained models
134
+
135
+ Currently, only [DinoV2](https://github.com/facebookresearch/dinov2/) have been ported, therefore the following
136
+ identifiers are available:
137
+
138
+ - `dinov2_vitb14.tar.lz4`
139
+ - `dinov2_vitb14_reg.tar.lz4`
140
+ - `dinov2_vitl14.tar.lz4`
141
+ - `dinov2_vitl14_reg.tar.lz4`
142
+ - `dinov2_vits14.tar.lz4`
143
+ - `dinov2_vits14_reg.tar.lz4`
144
+
145
+ (`giant` version coming soon)
146
+
147
+ ## Contributing
148
+
149
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
150
+
151
+ ## License
152
+
153
+ This project is licensed under the MIT License - see the LICENSE file for details.
154
+
155
+ ## Citation
156
+
157
+ If you use Equimo in your research, please cite:
158
+
159
+ ```bibtex
160
+ @software{equimo2024,
161
+ author = {Clément POIRET},
162
+ title = {Equimo: Modern Vision Models in JAX/Equinox},
163
+ year = {2024},
164
+ publisher = {GitHub},
165
+ url = {https://github.com/clementpoiret/equimo}
166
+ }
167
+ ```
equimo-0.2.0/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Equimo: Modern Vision Models in JAX/Equinox
2
+
3
+ **WARNING**: This is a research library implementing recent computer vision models. The implementations are based on paper descriptions and may not be exact replicas of the original implementations. Use with caution in production environments.
4
+
5
+ Equimo (Equinox Image Models) provides JAX/Equinox implementations of recent computer vision models, currently focusing (but not limited to) on transformer and state-space architectures.
6
+
7
+ ## Features
8
+
9
+ - Pure JAX/Equinox implementations
10
+ - Focus on recent architectures (2023-2024 papers)
11
+ - Modular design for easy experimentation
12
+ - Extensive documentation and type hints
13
+
14
+ ## Installation
15
+
16
+ ### From PyPI
17
+
18
+ ```bash
19
+ pip install equimo
20
+ ```
21
+
22
+ ### From Source
23
+
24
+ ```bash
25
+ git clone https://github.com/clementpoiret/equimo.git
26
+ cd equimo
27
+ pip install -e .
28
+ ```
29
+
30
+ ## Implemented Models
31
+
32
+ | Model | Paper | Year | Status |
33
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---- | --------- |
34
+ | FasterViT | [FasterViT: Fast Vision Transformers with Hierarchical Attention](https://arxiv.org/abs/2306.06189) | 2023 | ✅ |
35
+ | Castling-ViT | [Castling-ViT: Compressing Self-Attention via Switching Towards Linear-Angular Attention During Vision Transformer Inference](https://arxiv.org/abs/2211.10526) | 2023 | Partial\* |
36
+ | MLLA | [Mamba-like Linear Attention](https://arxiv.org/abs/2405.16605) | 2024 | ✅ |
37
+ | PartialFormer | [Efficient Vision Transformers with Partial Attention](https://eccv.ecva.net/virtual/2024/poster/1877) | 2024 | ✅ |
38
+ | SHViT | [SHViT: Single-Head Vision Transformer with Memory Efficient Macro Design](https://arxiv.org/abs/2401.16456) | 2024 | ✅ |
39
+ | VSSD | [VSSD: Vision Mamba with Non-Causal State Space Duality](https://arxiv.org/abs/2407.18559) | 2024 | ✅ |
40
+
41
+ \*: Only contains the [Linear Angular Attention](https://github.com/clementpoiret/Equimo/blob/f8fcc79e45ca65e9deb1d970c4286c0b8562f9c2/equimo/layers/attention.py#L1407) module. It is straight forward to build a ViT around it, but may require an additional `__call__` kwarg to control the `sparse_reg` bool.
42
+
43
+ ## Basic Usage
44
+
45
+ ```python
46
+ import jax
47
+
48
+ import equimo.models as em
49
+
50
+ # Create a model (e.g. `faster_vit_0_224`)
51
+ key = jax.random.PRNGKey(0)
52
+ model = em.FasterViT(
53
+ img_size=224,
54
+ in_channels=3,
55
+ dim=64,
56
+ in_dim=64,
57
+ depths=[2, 3, 6, 5],
58
+ num_heads=[2, 4, 8, 16],
59
+ hat=[False, False, True, False],
60
+ window_size=[7, 7, 7, 7],
61
+ ct_size=2,
62
+ key=key,
63
+ )
64
+
65
+ # Generate random input
66
+ x = jax.random.normal(key, (3, 224, 224))
67
+
68
+ # Run inference
69
+ output = model(x, enable_dropout=False, key=key)
70
+ ```
71
+
72
+ ## Saving and Loading Models
73
+
74
+ Equimo provides utilities for saving models locally and loading pre-trained models from the
75
+ [official repository](https://huggingface.co/poiretclement/equimo).
76
+
77
+ ### Saving Models Locally
78
+
79
+ ```python
80
+ from pathlib import Path
81
+ from equimo.io import save_model
82
+
83
+ # Save model with compression (creates .tar.lz4 file)
84
+ save_model(
85
+ Path("path/to/save/model"),
86
+ model, # can be any model you created using Equimo
87
+ model_config,
88
+ torch_hub_cfg, # This can be an empty list, it's mainly to keep track of where are the weights coming
89
+ compression=True
90
+ )
91
+
92
+ # Save model without compression (creates directory)
93
+ save_model(
94
+ Path("path/to/save/model"),
95
+ model,
96
+ model_config,
97
+ torch_hub_cfg,
98
+ compression=False
99
+ )
100
+ ```
101
+
102
+ ### Loading Models
103
+
104
+ ```python
105
+ from equimo.io import load_model
106
+
107
+ # Load a pre-trained model from the official repository
108
+ model = load_model(cls="vit", identifier="dinov2_vits14_reg")
109
+
110
+ # Load a local model (compressed)
111
+ model = load_model(cls="vit", path=Path("path/to/model.tar.lz4"))
112
+
113
+ # Load a local model (uncompressed directory)
114
+ model = load_model(cls="vit", path=Path("path/to/model/"))
115
+ ```
116
+
117
+ #### List of pretrained models
118
+
119
+ Currently, only [DinoV2](https://github.com/facebookresearch/dinov2/) have been ported, therefore the following
120
+ identifiers are available:
121
+
122
+ - `dinov2_vitb14.tar.lz4`
123
+ - `dinov2_vitb14_reg.tar.lz4`
124
+ - `dinov2_vitl14.tar.lz4`
125
+ - `dinov2_vitl14_reg.tar.lz4`
126
+ - `dinov2_vits14.tar.lz4`
127
+ - `dinov2_vits14_reg.tar.lz4`
128
+
129
+ (`giant` version coming soon)
130
+
131
+ ## Contributing
132
+
133
+ Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
134
+
135
+ ## License
136
+
137
+ This project is licensed under the MIT License - see the LICENSE file for details.
138
+
139
+ ## Citation
140
+
141
+ If you use Equimo in your research, please cite:
142
+
143
+ ```bibtex
144
+ @software{equimo2024,
145
+ author = {Clément POIRET},
146
+ title = {Equimo: Modern Vision Models in JAX/Equinox},
147
+ year = {2024},
148
+ publisher = {GitHub},
149
+ url = {https://github.com/clementpoiret/equimo}
150
+ }
151
+ ```
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,69 @@
1
+ from pathlib import Path
2
+
3
+ import jax
4
+
5
+ import equimo.models as em
6
+ from equimo.converters.utils import convert_torch_to_equinox
7
+ from equimo.io import load_model, save_model
8
+
9
+
10
+ def main():
11
+ key = jax.random.PRNGKey(42)
12
+ dinov2_vits14_reg_config = {
13
+ "img_size": 518,
14
+ "in_channels": 3,
15
+ "dim": 384,
16
+ "patch_size": 14,
17
+ "num_heads": [6],
18
+ "depths": [12],
19
+ "num_classes": 0,
20
+ "use_mask_token": True,
21
+ "reg_tokens": 4,
22
+ "init_values": 1e-5,
23
+ "eps": 1e-6,
24
+ "dynamic_img_size": True,
25
+ }
26
+
27
+ dinov2_vits14_reg = em.VisionTransformer(
28
+ **dinov2_vits14_reg_config,
29
+ key=key,
30
+ )
31
+
32
+ torch_hub_cfg = ["facebookresearch/dinov2", "dinov2_vits14_reg"]
33
+
34
+ replace_cfg = {
35
+ "reg_tokens": "register_tokens",
36
+ "blocks.0.blocks": "blocks",
37
+ ".prenorm.": ".norm1.",
38
+ ".norm.": ".norm2.",
39
+ }
40
+ expand_cfg = {"patch_embed.proj.bias": ["after", 2]}
41
+ squeeze_cfg = {
42
+ "pos_embed": 0,
43
+ "cls_token": 0,
44
+ "register_tokens": 0,
45
+ }
46
+ whitelist = []
47
+
48
+ dinov2_vits14_reg = convert_torch_to_equinox(
49
+ dinov2_vits14_reg,
50
+ torch_hub_cfg,
51
+ replace_cfg,
52
+ expand_cfg,
53
+ squeeze_cfg,
54
+ whitelist,
55
+ strict=True,
56
+ )
57
+
58
+ save_model(
59
+ Path("~/.cache/equimo/dinov2_vits14_reg").expanduser(),
60
+ dinov2_vits14_reg,
61
+ dinov2_vits14_reg_config,
62
+ torch_hub_cfg,
63
+ compression=True,
64
+ )
65
+
66
+ _ = load_model(
67
+ cls="vit",
68
+ path=Path("~/.cache/equimo/dinov2_vits14_reg.tar.lz4").expanduser(),
69
+ )