File size: 5,680 Bytes
c92f718
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42ab55f
c92f718
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42ab55f
 
 
 
 
 
 
 
c92f718
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
---
library_name: transformers
license: apple-ascl
metrics:
- accuracy
model-index:
- name: aimv2-3B-patch14-336
  results:
  - dataset:
      name: imagenet-1k
      type: imagenet-1k
    metrics:
    - name: Accuracy
      type: accuracy
      value: 89.2
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: inaturalist-18
      type: inaturalist-18
    metrics:
    - name: Accuracy
      type: accuracy
      value: 84.4
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: cifar10
      type: cifar10
    metrics:
    - name: Accuracy
      type: accuracy
      value: 99.5
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: cifar100
      type: cifar100
    metrics:
    - name: Accuracy
      type: accuracy
      value: 94.4
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: food101
      type: food101
    metrics:
    - name: Accuracy
      type: accuracy
      value: 97.2
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: dtd
      type: dtd
    metrics:
    - name: Accuracy
      type: accuracy
      value: 89.3
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: oxford-pets
      type: oxford-pets
    metrics:
    - name: Accuracy
      type: accuracy
      value: 97.2
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: stanford-cars
      type: stanford-cars
    metrics:
    - name: Accuracy
      type: accuracy
      value: 96.6
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: camelyon17
      type: camelyon17
    metrics:
    - name: Accuracy
      type: accuracy
      value: 93.2
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: patch-camelyon
      type: patch-camelyon
    metrics:
    - name: Accuracy
      type: accuracy
      value: 89.3
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: rxrx1
      type: rxrx1
    metrics:
    - name: Accuracy
      type: accuracy
      value: 8.8
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: eurosat
      type: eurosat
    metrics:
    - name: Accuracy
      type: accuracy
      value: 99.0
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: fmow
      type: fmow
    metrics:
    - name: Accuracy
      type: accuracy
      value: 65.7
      verified: false
    task:
      name: Classification
      type: classification
  - dataset:
      name: domainnet-infographic
      type: domainnet-infographic
    metrics:
    - name: Accuracy
      type: accuracy
      value: 74.0
      verified: false
    task:
      name: Classification
      type: classification
pipeline_tag: image-feature-extraction
tags:
- vision
- image-feature-extraction
- mlx
- pytorch
---
# Introduction
[[`AIMv2 Paper`](https://arxiv.org/abs/2411.14402)] [[`BibTeX`](#citation)]

We introduce the AIMv2 family of vision models pre-trained with a multimodal autoregressive objective.
AIMv2 pre-training is simple and straightforward to train and scale effectively. Some AIMv2 highlights include:

1. Outperforms OAI CLIP and SigLIP on the majority of multimodal understanding benchmarks.
2. Outperforms DINOv2 on open-vocabulary object detection and referring expression comprehension.
3. Exhibits strong recognition performance with AIMv2-3B achieving *89.5% on ImageNet using a frozen trunk*.

<img src="aimv2_overview_light.png" alt="AIMv2 Overview"/>

## Usage

### PyTorch
```python
import requests
from PIL import Image
from transformers import AutoImageProcessor, AutoModel

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

processor = AutoImageProcessor.from_pretrained(
    "apple/aimv2-3B-patch14-336",
)
model = AutoModel.from_pretrained(
    "apple/aimv2-3B-patch14-336",
    trust_remote_code=True,
)

inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
```

### JAX
```python
import requests
from PIL import Image
from transformers import AutoImageProcessor, FlaxAutoModel

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

processor = AutoImageProcessor.from_pretrained(
    "apple/aimv2-3B-patch14-336",
)
model = FlaxAutoModel.from_pretrained(
    "apple/aimv2-3B-patch14-336",
    trust_remote_code=True,
)

inputs = processor(images=image, return_tensors="jax")
outputs = model(**inputs)
```

## Citation
If you find our work useful, please consider citing us as:
```bibtex
@misc{fini2024multimodalautoregressivepretraininglarge,
  author      = {Fini, Enrico and Shukor, Mustafa and Li, Xiujun and Dufter, Philipp and Klein, Michal and Haldimann, David and Aitharaju, Sai and da Costa, Victor Guilherme Turrisi and Béthune, Louis and Gan, Zhe and Toshev, Alexander T and Eichner, Marcin and Nabi, Moin and Yang, Yinfei and Susskind, Joshua M. and El-Nouby, Alaaeldin},
  url         = {https://arxiv.org/abs/2411.14402},
  eprint      = {2411.14402},
  eprintclass = {cs.CV},
  eprinttype  = {arXiv},
  title       = {Multimodal Autoregressive Pre-training of Large Vision Encoders},
  year        = {2024},
}
```