danielhanchen commited on
Commit
2d7643e
·
verified ·
1 Parent(s): 58a8e36

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ mmproj-F16.gguf filter=lfs diff=lfs merge=lfs -text
37
+ Qwen2.5-VL-7B-Instruct-UD-IQ1_M.gguf filter=lfs diff=lfs merge=lfs -text
38
+ Qwen2.5-VL-7B-Instruct-UD-IQ1_S.gguf filter=lfs diff=lfs merge=lfs -text
39
+ mmproj-F32.gguf filter=lfs diff=lfs merge=lfs -text
40
+ Qwen2.5-VL-7B-Instruct-UD-IQ2_M.gguf filter=lfs diff=lfs merge=lfs -text
41
+ Qwen2.5-VL-7B-Instruct-UD-IQ3_XXS.gguf filter=lfs diff=lfs merge=lfs -text
42
+ Qwen2.5-VL-7B-Instruct-UD-Q2_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
43
+ Qwen2.5-VL-7B-Instruct-UD-Q3_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
44
+ Qwen2.5-VL-7B-Instruct-UD-Q4_K_XL.gguf filter=lfs diff=lfs merge=lfs -text
Qwen2.5-VL-7B-Instruct-UD-IQ1_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52262543bfd558324913da35521a5ec4724e8dfa1387ef2c3e1f3453f1eaf923
3
+ size 2200536384
Qwen2.5-VL-7B-Instruct-UD-IQ1_S.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6fa67f7160aa5c62e8edeb449b7326009f3a79d1fdbb88b18c44449d69a62d6
3
+ size 2073763136
Qwen2.5-VL-7B-Instruct-UD-IQ2_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93d03098929ea6ff3ffaef58a6d619fee6918db23ce5ea2f682bfccc517e8ca7
3
+ size 2856250688
Qwen2.5-VL-7B-Instruct-UD-IQ3_XXS.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5677ec071dec6ce9147b5ddb61b79c794b47dd97029775e8d58c16116ab8b0d
3
+ size 3167198528
Qwen2.5-VL-7B-Instruct-UD-Q2_K_XL.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec5b1af3846d784dcc6b32aa0bb484350841cdbc51035d6a57d669e9aa0d00a2
3
+ size 3242949952
Qwen2.5-VL-7B-Instruct-UD-Q3_K_XL.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e75bfa531ee208fbf949518b41ca6f5a48378ec004c969c7767f1acb77c0474e
3
+ size 4002671936
Qwen2.5-VL-7B-Instruct-UD-Q4_K_XL.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78fcb565896bc06b4ceb6e33468c87fb13075fb80fceea2e0f9c717ea99a2b5b
3
+ size 4785159488
README.md ADDED
@@ -0,0 +1,530 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - Qwen/Qwen2.5-VL-7B-Instruct
4
+ license: apache-2.0
5
+ language:
6
+ - en
7
+ pipeline_tag: image-text-to-text
8
+ tags:
9
+ - multimodal
10
+ - unsloth
11
+ library_name: transformers
12
+ ---
13
+
14
+ # Qwen2.5-VL-7B-Instruct
15
+ <a href="https://chat.qwenlm.ai/" target="_blank" style="margin: 2px;">
16
+ <img alt="Chat" src="https://img.shields.io/badge/%F0%9F%92%9C%EF%B8%8F%20Qwen%20Chat%20-536af5" style="display: inline-block; vertical-align: middle;"/>
17
+ </a>
18
+
19
+ ## Introduction
20
+
21
+ In the past five months since Qwen2-VL’s release, numerous developers have built new models on the Qwen2-VL vision-language models, providing us with valuable feedback. During this period, we focused on building more useful vision-language models. Today, we are excited to introduce the latest addition to the Qwen family: Qwen2.5-VL.
22
+
23
+ #### Key Enhancements:
24
+ * **Understand things visually**: Qwen2.5-VL is not only proficient in recognizing common objects such as flowers, birds, fish, and insects, but it is highly capable of analyzing texts, charts, icons, graphics, and layouts within images.
25
+
26
+ * **Being agentic**: Qwen2.5-VL directly plays as a visual agent that can reason and dynamically direct tools, which is capable of computer use and phone use.
27
+
28
+ * **Understanding long videos and capturing events**: Qwen2.5-VL can comprehend videos of over 1 hour, and this time it has a new ability of cpaturing event by pinpointing the relevant video segments.
29
+
30
+ * **Capable of visual localization in different formats**: Qwen2.5-VL can accurately localize objects in an image by generating bounding boxes or points, and it can provide stable JSON outputs for coordinates and attributes.
31
+
32
+ * **Generating structured outputs**: for data like scans of invoices, forms, tables, etc. Qwen2.5-VL supports structured outputs of their contents, benefiting usages in finance, commerce, etc.
33
+
34
+
35
+ #### Model Architecture Updates:
36
+
37
+ * **Dynamic Resolution and Frame Rate Training for Video Understanding**:
38
+
39
+ We extend dynamic resolution to the temporal dimension by adopting dynamic FPS sampling, enabling the model to comprehend videos at various sampling rates. Accordingly, we update mRoPE in the time dimension with IDs and absolute time alignment, enabling the model to learn temporal sequence and speed, and ultimately acquire the ability to pinpoint specific moments.
40
+
41
+ <p align="center">
42
+ <img src="https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2.5-VL/qwen2.5vl_arc.jpeg" width="80%"/>
43
+ <p>
44
+
45
+
46
+ * **Streamlined and Efficient Vision Encoder**
47
+
48
+ We enhance both training and inference speeds by strategically implementing window attention into the ViT. The ViT architecture is further optimized with SwiGLU and RMSNorm, aligning it with the structure of the Qwen2.5 LLM.
49
+
50
+
51
+ We have three models with 3, 7 and 72 billion parameters. This repo contains the instruction-tuned 7B Qwen2.5-VL model. For more information, visit our [Blog](https://qwenlm.github.io/blog/qwen2.5-vl/) and [GitHub](https://github.com/QwenLM/Qwen2.5-VL).
52
+
53
+
54
+
55
+ ## Evaluation
56
+
57
+ ### Image benchmark
58
+
59
+
60
+ | Benchmark | InternVL2.5-8B | MiniCPM-o 2.6 | GPT-4o-mini | Qwen2-VL-7B |**Qwen2.5-VL-7B** |
61
+ | :--- | :---: | :---: | :---: | :---: | :---: |
62
+ | MMMU<sub>val</sub> | 56 | 50.4 | **60**| 54.1 | 58.6|
63
+ | MMMU-Pro<sub>val</sub> | 34.3 | - | 37.6| 30.5 | 41.0|
64
+ | DocVQA<sub>test</sub> | 93 | 93 | - | 94.5 | **95.7** |
65
+ | InfoVQA<sub>test</sub> | 77.6 | - | - |76.5 | **82.6** |
66
+ | ChartQA<sub>test</sub> | 84.8 | - |- | 83.0 |**87.3** |
67
+ | TextVQA<sub>val</sub> | 79.1 | 80.1 | -| 84.3 | **84.9**|
68
+ | OCRBench | 822 | 852 | 785 | 845 | **864** |
69
+ | CC_OCR | 57.7 | | | 61.6 | **77.8**|
70
+ | MMStar | 62.8| | |60.7| **63.9**|
71
+ | MMBench-V1.1-En<sub>test</sub> | 79.4 | 78.0 | 76.0| 80.7 | **82.6** |
72
+ | MMT-Bench<sub>test</sub> | - | - | - |**63.7** |63.6 |
73
+ | MMStar | **61.5** | 57.5 | 54.8 | 60.7 |63.9 |
74
+ | MMVet<sub>GPT-4-Turbo</sub> | 54.2 | 60.0 | 66.9 | 62.0 | **67.1**|
75
+ | HallBench<sub>avg</sub> | 45.2 | 48.1 | 46.1| 50.6 | **52.9**|
76
+ | MathVista<sub>testmini</sub> | 58.3 | 60.6 | 52.4 | 58.2 | **68.2**|
77
+ | MathVision | - | - | - | 16.3 | **25.07** |
78
+
79
+ ### Video Benchmarks
80
+
81
+ | Benchmark | Qwen2-VL-7B | **Qwen2.5-VL-7B** |
82
+ | :--- | :---: | :---: |
83
+ | MVBench | 67.0 | **69.6** |
84
+ | PerceptionTest<sub>test</sub> | 66.9 | **70.5** |
85
+ | Video-MME<sub>wo/w subs</sub> | 63.3/69.0 | **65.1**/**71.6** |
86
+ | LVBench | | 45.3 |
87
+ | LongVideoBench | | 54.7 |
88
+ | MMBench-Video | 1.44 | 1.79 |
89
+ | TempCompass | | 71.7 |
90
+ | MLVU | | 70.2 |
91
+ | CharadesSTA/mIoU | 43.6|
92
+
93
+ ### Agent benchmark
94
+ | Benchmarks | Qwen2.5-VL-7B |
95
+ |-------------------------|---------------|
96
+ | ScreenSpot | 84.7 |
97
+ | ScreenSpot Pro | 29.0 |
98
+ | AITZ_EM | 81.9 |
99
+ | Android Control High_EM | 60.1 |
100
+ | Android Control Low_EM | 93.7 |
101
+ | AndroidWorld_SR | 25.5 |
102
+ | MobileMiniWob++_SR | 91.4 |
103
+
104
+ ## Requirements
105
+ The code of Qwen2.5-VL has been in the latest Hugging face transformers and we advise you to build from source with command:
106
+ ```
107
+ pip install git+https://github.com/huggingface/transformers accelerate
108
+ ```
109
+ or you might encounter the following error:
110
+ ```
111
+ KeyError: 'qwen2_5_vl'
112
+ ```
113
+
114
+
115
+ ## Quickstart
116
+
117
+ Below, we provide simple examples to show how to use Qwen2.5-VL with 🤖 ModelScope and 🤗 Transformers.
118
+
119
+ The code of Qwen2.5-VL has been in the latest Hugging face transformers and we advise you to build from source with command:
120
+ ```
121
+ pip install git+https://github.com/huggingface/transformers accelerate
122
+ ```
123
+ or you might encounter the following error:
124
+ ```
125
+ KeyError: 'qwen2_5_vl'
126
+ ```
127
+
128
+
129
+ We offer a toolkit to help you handle various types of visual input more conveniently, as if you were using an API. This includes base64, URLs, and interleaved images and videos. You can install it using the following command:
130
+
131
+ ```bash
132
+ # It's highly recommanded to use `[decord]` feature for faster video loading.
133
+ pip install qwen-vl-utils[decord]==0.0.8
134
+ ```
135
+
136
+ If you are not using Linux, you might not be able to install `decord` from PyPI. In that case, you can use `pip install qwen-vl-utils` which will fall back to using torchvision for video processing. However, you can still [install decord from source](https://github.com/dmlc/decord?tab=readme-ov-file#install-from-source) to get decord used when loading video.
137
+
138
+ ### Using 🤗 Transformers to Chat
139
+
140
+ Here we show a code snippet to show you how to use the chat model with `transformers` and `qwen_vl_utils`:
141
+
142
+ ```python
143
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
144
+ from qwen_vl_utils import process_vision_info
145
+
146
+ # default: Load the model on the available device(s)
147
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
148
+ "Qwen/Qwen2.5-VL-7B-Instruct", torch_dtype="auto", device_map="auto"
149
+ )
150
+
151
+ # We recommend enabling flash_attention_2 for better acceleration and memory saving, especially in multi-image and video scenarios.
152
+ # model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
153
+ # "Qwen/Qwen2.5-VL-7B-Instruct",
154
+ # torch_dtype=torch.bfloat16,
155
+ # attn_implementation="flash_attention_2",
156
+ # device_map="auto",
157
+ # )
158
+
159
+ # default processer
160
+ processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct")
161
+
162
+ # The default range for the number of visual tokens per image in the model is 4-16384.
163
+ # You can set min_pixels and max_pixels according to your needs, such as a token range of 256-1280, to balance performance and cost.
164
+ # min_pixels = 256*28*28
165
+ # max_pixels = 1280*28*28
166
+ # processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels)
167
+
168
+ messages = [
169
+ {
170
+ "role": "user",
171
+ "content": [
172
+ {
173
+ "type": "image",
174
+ "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
175
+ },
176
+ {"type": "text", "text": "Describe this image."},
177
+ ],
178
+ }
179
+ ]
180
+
181
+ # Preparation for inference
182
+ text = processor.apply_chat_template(
183
+ messages, tokenize=False, add_generation_prompt=True
184
+ )
185
+ image_inputs, video_inputs = process_vision_info(messages)
186
+ inputs = processor(
187
+ text=[text],
188
+ images=image_inputs,
189
+ videos=video_inputs,
190
+ padding=True,
191
+ return_tensors="pt",
192
+ )
193
+ inputs = inputs.to("cuda")
194
+
195
+ # Inference: Generation of the output
196
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
197
+ generated_ids_trimmed = [
198
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
199
+ ]
200
+ output_text = processor.batch_decode(
201
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
202
+ )
203
+ print(output_text)
204
+ ```
205
+ <details>
206
+ <summary>Multi image inference</summary>
207
+
208
+ ```python
209
+ # Messages containing multiple images and a text query
210
+ messages = [
211
+ {
212
+ "role": "user",
213
+ "content": [
214
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
215
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
216
+ {"type": "text", "text": "Identify the similarities between these images."},
217
+ ],
218
+ }
219
+ ]
220
+
221
+ # Preparation for inference
222
+ text = processor.apply_chat_template(
223
+ messages, tokenize=False, add_generation_prompt=True
224
+ )
225
+ image_inputs, video_inputs = process_vision_info(messages)
226
+ inputs = processor(
227
+ text=[text],
228
+ images=image_inputs,
229
+ videos=video_inputs,
230
+ padding=True,
231
+ return_tensors="pt",
232
+ )
233
+ inputs = inputs.to("cuda")
234
+
235
+ # Inference
236
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
237
+ generated_ids_trimmed = [
238
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
239
+ ]
240
+ output_text = processor.batch_decode(
241
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
242
+ )
243
+ print(output_text)
244
+ ```
245
+ </details>
246
+
247
+ <details>
248
+ <summary>Video inference</summary>
249
+
250
+ ```python
251
+ # Messages containing a images list as a video and a text query
252
+ messages = [
253
+ {
254
+ "role": "user",
255
+ "content": [
256
+ {
257
+ "type": "video",
258
+ "video": [
259
+ "file:///path/to/frame1.jpg",
260
+ "file:///path/to/frame2.jpg",
261
+ "file:///path/to/frame3.jpg",
262
+ "file:///path/to/frame4.jpg",
263
+ ],
264
+ },
265
+ {"type": "text", "text": "Describe this video."},
266
+ ],
267
+ }
268
+ ]
269
+
270
+ # Messages containing a local video path and a text query
271
+ messages = [
272
+ {
273
+ "role": "user",
274
+ "content": [
275
+ {
276
+ "type": "video",
277
+ "video": "file:///path/to/video1.mp4",
278
+ "max_pixels": 360 * 420,
279
+ "fps": 1.0,
280
+ },
281
+ {"type": "text", "text": "Describe this video."},
282
+ ],
283
+ }
284
+ ]
285
+
286
+ # Messages containing a video url and a text query
287
+ messages = [
288
+ {
289
+ "role": "user",
290
+ "content": [
291
+ {
292
+ "type": "video",
293
+ "video": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen2-VL/space_woaudio.mp4",
294
+ },
295
+ {"type": "text", "text": "Describe this video."},
296
+ ],
297
+ }
298
+ ]
299
+
300
+ #In Qwen 2.5 VL, frame rate information is also input into the model to align with absolute time.
301
+ # Preparation for inference
302
+ text = processor.apply_chat_template(
303
+ messages, tokenize=False, add_generation_prompt=True
304
+ )
305
+ image_inputs, video_inputs, video_kwargs = process_vision_info(messages, return_video_kwargs=True)
306
+ inputs = processor(
307
+ text=[text],
308
+ images=image_inputs,
309
+ videos=video_inputs,
310
+ fps=fps,
311
+ padding=True,
312
+ return_tensors="pt",
313
+ **video_kwargs,
314
+ )
315
+ inputs = inputs.to("cuda")
316
+
317
+ # Inference
318
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
319
+ generated_ids_trimmed = [
320
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
321
+ ]
322
+ output_text = processor.batch_decode(
323
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
324
+ )
325
+ print(output_text)
326
+ ```
327
+
328
+ Video URL compatibility largely depends on the third-party library version. The details are in the table below. change the backend by `FORCE_QWENVL_VIDEO_READER=torchvision` or `FORCE_QWENVL_VIDEO_READER=decord` if you prefer not to use the default one.
329
+
330
+ | Backend | HTTP | HTTPS |
331
+ |-------------|------|-------|
332
+ | torchvision >= 0.19.0 | ✅ | ✅ |
333
+ | torchvision < 0.19.0 | ❌ | ❌ |
334
+ | decord | ✅ | ❌ |
335
+ </details>
336
+
337
+ <details>
338
+ <summary>Batch inference</summary>
339
+
340
+ ```python
341
+ # Sample messages for batch inference
342
+ messages1 = [
343
+ {
344
+ "role": "user",
345
+ "content": [
346
+ {"type": "image", "image": "file:///path/to/image1.jpg"},
347
+ {"type": "image", "image": "file:///path/to/image2.jpg"},
348
+ {"type": "text", "text": "What are the common elements in these pictures?"},
349
+ ],
350
+ }
351
+ ]
352
+ messages2 = [
353
+ {"role": "system", "content": "You are a helpful assistant."},
354
+ {"role": "user", "content": "Who are you?"},
355
+ ]
356
+ # Combine messages for batch processing
357
+ messages = [messages1, messages2]
358
+
359
+ # Preparation for batch inference
360
+ texts = [
361
+ processor.apply_chat_template(msg, tokenize=False, add_generation_prompt=True)
362
+ for msg in messages
363
+ ]
364
+ image_inputs, video_inputs = process_vision_info(messages)
365
+ inputs = processor(
366
+ text=texts,
367
+ images=image_inputs,
368
+ videos=video_inputs,
369
+ padding=True,
370
+ return_tensors="pt",
371
+ )
372
+ inputs = inputs.to("cuda")
373
+
374
+ # Batch Inference
375
+ generated_ids = model.generate(**inputs, max_new_tokens=128)
376
+ generated_ids_trimmed = [
377
+ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
378
+ ]
379
+ output_texts = processor.batch_decode(
380
+ generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
381
+ )
382
+ print(output_texts)
383
+ ```
384
+ </details>
385
+
386
+ ### 🤖 ModelScope
387
+ We strongly advise users especially those in mainland China to use ModelScope. `snapshot_download` can help you solve issues concerning downloading checkpoints.
388
+
389
+
390
+ ### More Usage Tips
391
+
392
+ For input images, we support local files, base64, and URLs. For videos, we currently only support local files.
393
+
394
+ ```python
395
+ # You can directly insert a local file path, a URL, or a base64-encoded image into the position where you want in the text.
396
+ ## Local file path
397
+ messages = [
398
+ {
399
+ "role": "user",
400
+ "content": [
401
+ {"type": "image", "image": "file:///path/to/your/image.jpg"},
402
+ {"type": "text", "text": "Describe this image."},
403
+ ],
404
+ }
405
+ ]
406
+ ## Image URL
407
+ messages = [
408
+ {
409
+ "role": "user",
410
+ "content": [
411
+ {"type": "image", "image": "http://path/to/your/image.jpg"},
412
+ {"type": "text", "text": "Describe this image."},
413
+ ],
414
+ }
415
+ ]
416
+ ## Base64 encoded image
417
+ messages = [
418
+ {
419
+ "role": "user",
420
+ "content": [
421
+ {"type": "image", "image": "data:image;base64,/9j/..."},
422
+ {"type": "text", "text": "Describe this image."},
423
+ ],
424
+ }
425
+ ]
426
+ ```
427
+ #### Image Resolution for performance boost
428
+
429
+ The model supports a wide range of resolution inputs. By default, it uses the native resolution for input, but higher resolutions can enhance performance at the cost of more computation. Users can set the minimum and maximum number of pixels to achieve an optimal configuration for their needs, such as a token count range of 256-1280, to balance speed and memory usage.
430
+
431
+ ```python
432
+ min_pixels = 256 * 28 * 28
433
+ max_pixels = 1280 * 28 * 28
434
+ processor = AutoProcessor.from_pretrained(
435
+ "Qwen/Qwen2.5-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels
436
+ )
437
+ ```
438
+
439
+ Besides, We provide two methods for fine-grained control over the image size input to the model:
440
+
441
+ 1. Define min_pixels and max_pixels: Images will be resized to maintain their aspect ratio within the range of min_pixels and max_pixels.
442
+
443
+ 2. Specify exact dimensions: Directly set `resized_height` and `resized_width`. These values will be rounded to the nearest multiple of 28.
444
+
445
+ ```python
446
+ # min_pixels and max_pixels
447
+ messages = [
448
+ {
449
+ "role": "user",
450
+ "content": [
451
+ {
452
+ "type": "image",
453
+ "image": "file:///path/to/your/image.jpg",
454
+ "resized_height": 280,
455
+ "resized_width": 420,
456
+ },
457
+ {"type": "text", "text": "Describe this image."},
458
+ ],
459
+ }
460
+ ]
461
+ # resized_height and resized_width
462
+ messages = [
463
+ {
464
+ "role": "user",
465
+ "content": [
466
+ {
467
+ "type": "image",
468
+ "image": "file:///path/to/your/image.jpg",
469
+ "min_pixels": 50176,
470
+ "max_pixels": 50176,
471
+ },
472
+ {"type": "text", "text": "Describe this image."},
473
+ ],
474
+ }
475
+ ]
476
+ ```
477
+
478
+ ### Processing Long Texts
479
+
480
+ The current `config.json` is set for context length up to 32,768 tokens.
481
+ To handle extensive inputs exceeding 32,768 tokens, we utilize [YaRN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
482
+
483
+ For supported frameworks, you could add the following to `config.json` to enable YaRN:
484
+
485
+ {
486
+ ...,
487
+ "type": "yarn",
488
+ "mrope_section": [
489
+ 16,
490
+ 24,
491
+ 24
492
+ ],
493
+ "factor": 4,
494
+ "original_max_position_embeddings": 32768
495
+ }
496
+
497
+ However, it should be noted that this method has a significant impact on the performance of temporal and spatial localization tasks, and is therefore not recommended for use.
498
+
499
+ At the same time, for long video inputs, since MRoPE itself is more economical with ids, the max_position_embeddings can be directly modified to a larger value, such as 64k.
500
+
501
+
502
+
503
+
504
+ ## Citation
505
+
506
+ If you find our work helpful, feel free to give us a cite.
507
+
508
+ ```
509
+ @misc{qwen2.5-VL,
510
+ title = {Qwen2.5-VL},
511
+ url = {https://qwenlm.github.io/blog/qwen2.5-vl/},
512
+ author = {Qwen Team},
513
+ month = {January},
514
+ year = {2025}
515
+ }
516
+
517
+ @article{Qwen2VL,
518
+ title={Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution},
519
+ author={Wang, Peng and Bai, Shuai and Tan, Sinan and Wang, Shijie and Fan, Zhihao and Bai, Jinze and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Fan, Yang and Dang, Kai and Du, Mengfei and Ren, Xuancheng and Men, Rui and Liu, Dayiheng and Zhou, Chang and Zhou, Jingren and Lin, Junyang},
520
+ journal={arXiv preprint arXiv:2409.12191},
521
+ year={2024}
522
+ }
523
+
524
+ @article{Qwen-VL,
525
+ title={Qwen-VL: A Versatile Vision-Language Model for Understanding, Localization, Text Reading, and Beyond},
526
+ author={Bai, Jinze and Bai, Shuai and Yang, Shusheng and Wang, Shijie and Tan, Sinan and Wang, Peng and Lin, Junyang and Zhou, Chang and Zhou, Jingren},
527
+ journal={arXiv preprint arXiv:2308.12966},
528
+ year={2023}
529
+ }
530
+ ```
config.json ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2_5_VLForConditionalGeneration"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "eos_token_id": 151645,
7
+ "hidden_act": "silu",
8
+ "hidden_size": 3584,
9
+ "image_token_id": 151655,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 18944,
12
+ "max_position_embeddings": 128000,
13
+ "max_window_layers": 28,
14
+ "model_type": "qwen2_5_vl",
15
+ "num_attention_heads": 28,
16
+ "num_hidden_layers": 28,
17
+ "num_key_value_heads": 4,
18
+ "pad_token_id": 151654,
19
+ "rms_norm_eps": 1e-06,
20
+ "rope_scaling": {
21
+ "mrope_section": [
22
+ 16,
23
+ 24,
24
+ 24
25
+ ],
26
+ "rope_type": "default",
27
+ "type": "default"
28
+ },
29
+ "rope_theta": 1000000.0,
30
+ "sliding_window": 32768,
31
+ "text_config": {
32
+ "architectures": [
33
+ "Qwen2_5_VLForConditionalGeneration"
34
+ ],
35
+ "attention_dropout": 0.0,
36
+ "bos_token_id": 151643,
37
+ "eos_token_id": 151645,
38
+ "hidden_act": "silu",
39
+ "hidden_size": 3584,
40
+ "image_token_id": null,
41
+ "initializer_range": 0.02,
42
+ "intermediate_size": 18944,
43
+ "max_position_embeddings": 128000,
44
+ "max_window_layers": 28,
45
+ "model_type": "qwen2_5_vl_text",
46
+ "num_attention_heads": 28,
47
+ "num_hidden_layers": 28,
48
+ "num_key_value_heads": 4,
49
+ "rms_norm_eps": 1e-06,
50
+ "rope_scaling": {
51
+ "mrope_section": [
52
+ 16,
53
+ 24,
54
+ 24
55
+ ],
56
+ "rope_type": "default",
57
+ "type": "default"
58
+ },
59
+ "rope_theta": 1000000.0,
60
+ "sliding_window": 32768,
61
+ "torch_dtype": "bfloat16",
62
+ "use_cache": true,
63
+ "use_sliding_window": false,
64
+ "video_token_id": null,
65
+ "vision_end_token_id": 151653,
66
+ "vision_start_token_id": 151652,
67
+ "vision_token_id": 151654,
68
+ "vocab_size": 152064
69
+ },
70
+ "tie_word_embeddings": false,
71
+ "torch_dtype": "bfloat16",
72
+ "transformers_version": "4.52.0.dev0",
73
+ "unsloth_fixed": true,
74
+ "use_cache": true,
75
+ "use_sliding_window": false,
76
+ "video_token_id": 151656,
77
+ "vision_config": {
78
+ "depth": 32,
79
+ "fullatt_block_indexes": [
80
+ 7,
81
+ 15,
82
+ 23,
83
+ 31
84
+ ],
85
+ "hidden_act": "silu",
86
+ "hidden_size": 1280,
87
+ "in_channels": 3,
88
+ "in_chans": 3,
89
+ "initializer_range": 0.02,
90
+ "intermediate_size": 3420,
91
+ "model_type": "qwen2_5_vl",
92
+ "num_heads": 16,
93
+ "out_hidden_size": 3584,
94
+ "patch_size": 14,
95
+ "spatial_merge_size": 2,
96
+ "spatial_patch_size": 14,
97
+ "temporal_patch_size": 2,
98
+ "tokens_per_second": 2,
99
+ "torch_dtype": "bfloat16",
100
+ "window_size": 112
101
+ },
102
+ "vision_end_token_id": 151653,
103
+ "vision_start_token_id": 151652,
104
+ "vision_token_id": 151654,
105
+ "vocab_size": 152064
106
+ }
mmproj-F16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d90339a0e5859584acedfe3ce47832ff834faafaabd015338f55a2468a57b6a5
3
+ size 1354163488
mmproj-F32.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0faf27b16dd197313e8a8a9d04c32b78c0db920dddcd1faeb0b47f7959469962
3
+ size 2703222048