pcuenq HF staff rwightman HF staff commited on
Commit
46faa97
·
verified ·
0 Parent(s):

Duplicate from timm/vit_large_patch14_dinov2.lvd142m

Browse files

Co-authored-by: Ross Wightman <[email protected]>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +112 -0
  3. config.json +34 -0
  4. model.safetensors +3 -0
  5. pytorch_model.bin +3 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: timm
4
+ tags:
5
+ - image-feature-extraction
6
+ - timm
7
+ - transformers
8
+ ---
9
+ # Model card for vit_large_patch14_dinov2.lvd142m
10
+
11
+ A Vision Transformer (ViT) image feature model. Pretrained on LVD-142M with self-supervised DINOv2 method.
12
+
13
+
14
+ ## Model Details
15
+ - **Model Type:** Image classification / feature backbone
16
+ - **Model Stats:**
17
+ - Params (M): 304.4
18
+ - GMACs: 507.1
19
+ - Activations (M): 1058.8
20
+ - Image size: 518 x 518
21
+ - **Papers:**
22
+ - DINOv2: Learning Robust Visual Features without Supervision: https://arxiv.org/abs/2304.07193
23
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: https://arxiv.org/abs/2010.11929v2
24
+ - **Original:** https://github.com/facebookresearch/dinov2
25
+ - **Pretrain Dataset:** LVD-142M
26
+
27
+ ## Model Usage
28
+ ### Image Classification
29
+ ```python
30
+ from urllib.request import urlopen
31
+ from PIL import Image
32
+ import timm
33
+
34
+ img = Image.open(urlopen(
35
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
36
+ ))
37
+
38
+ model = timm.create_model('vit_large_patch14_dinov2.lvd142m', pretrained=True)
39
+ model = model.eval()
40
+
41
+ # get model specific transforms (normalization, resize)
42
+ data_config = timm.data.resolve_model_data_config(model)
43
+ transforms = timm.data.create_transform(**data_config, is_training=False)
44
+
45
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
46
+
47
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
48
+ ```
49
+
50
+ ### Image Embeddings
51
+ ```python
52
+ from urllib.request import urlopen
53
+ from PIL import Image
54
+ import timm
55
+
56
+ img = Image.open(urlopen(
57
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
58
+ ))
59
+
60
+ model = timm.create_model(
61
+ 'vit_large_patch14_dinov2.lvd142m',
62
+ pretrained=True,
63
+ num_classes=0, # remove classifier nn.Linear
64
+ )
65
+ model = model.eval()
66
+
67
+ # get model specific transforms (normalization, resize)
68
+ data_config = timm.data.resolve_model_data_config(model)
69
+ transforms = timm.data.create_transform(**data_config, is_training=False)
70
+
71
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
72
+
73
+ # or equivalently (without needing to set num_classes=0)
74
+
75
+ output = model.forward_features(transforms(img).unsqueeze(0))
76
+ # output is unpooled, a (1, 1370, 1024) shaped tensor
77
+
78
+ output = model.forward_head(output, pre_logits=True)
79
+ # output is a (1, num_features) shaped tensor
80
+ ```
81
+
82
+ ## Model Comparison
83
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
84
+
85
+ ## Citation
86
+ ```bibtex
87
+ @misc{oquab2023dinov2,
88
+ title={DINOv2: Learning Robust Visual Features without Supervision},
89
+ author={Oquab, Maxime and Darcet, Timothée and Moutakanni, Theo and Vo, Huy V. and Szafraniec, Marc and Khalidov, Vasil and Fernandez, Pierre and Haziza, Daniel and Massa, Francisco and El-Nouby, Alaaeldin and Howes, Russell and Huang, Po-Yao and Xu, Hu and Sharma, Vasu and Li, Shang-Wen and Galuba, Wojciech and Rabbat, Mike and Assran, Mido and Ballas, Nicolas and Synnaeve, Gabriel and Misra, Ishan and Jegou, Herve and Mairal, Julien and Labatut, Patrick and Joulin, Armand and Bojanowski, Piotr},
90
+ journal={arXiv:2304.07193},
91
+ year={2023}
92
+ }
93
+ ```
94
+ ```bibtex
95
+ @article{dosovitskiy2020vit,
96
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
97
+ author={Dosovitskiy, Alexey and Beyer, Lucas and Kolesnikov, Alexander and Weissenborn, Dirk and Zhai, Xiaohua and Unterthiner, Thomas and Dehghani, Mostafa and Minderer, Matthias and Heigold, Georg and Gelly, Sylvain and Uszkoreit, Jakob and Houlsby, Neil},
98
+ journal={ICLR},
99
+ year={2021}
100
+ }
101
+ ```
102
+ ```bibtex
103
+ @misc{rw2019timm,
104
+ author = {Ross Wightman},
105
+ title = {PyTorch Image Models},
106
+ year = {2019},
107
+ publisher = {GitHub},
108
+ journal = {GitHub repository},
109
+ doi = {10.5281/zenodo.4414861},
110
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
111
+ }
112
+ ```
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "vit_large_patch14_dinov2",
3
+ "num_classes": 0,
4
+ "num_features": 1024,
5
+ "global_pool": "token",
6
+ "pretrained_cfg": {
7
+ "tag": "lvd142m",
8
+ "custom_load": false,
9
+ "input_size": [
10
+ 3,
11
+ 518,
12
+ 518
13
+ ],
14
+ "fixed_input_size": true,
15
+ "interpolation": "bicubic",
16
+ "crop_pct": 1.0,
17
+ "crop_mode": "center",
18
+ "mean": [
19
+ 0.485,
20
+ 0.456,
21
+ 0.406
22
+ ],
23
+ "std": [
24
+ 0.229,
25
+ 0.224,
26
+ 0.225
27
+ ],
28
+ "num_classes": 0,
29
+ "pool_size": null,
30
+ "first_conv": "patch_embed.proj",
31
+ "classifier": "head",
32
+ "license": "cc-by-nc-4.0"
33
+ }
34
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0424a5d1b515278cba3c6640ccbeaacc41de59d3a93df0dd5e494285eea2b355
3
+ size 1217502758
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96413a203d0d00d673ae8de0a28959ae42f280106fa047b399fe9233fd31855c
3
+ size 1217595109