Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
3336c8cf
Unverified
Commit
3336c8cf
authored
Jun 04, 2025
by
汪志鹏
Committed by
GitHub
Jun 04, 2025
Browse files
Fix #19130 (#19132)
Signed-off-by:
汪志鹏
<
wangzhipeng628@gmail.com
>
parent
b124e108
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
examples/offline_inference/vision_language_multi_image.py
examples/offline_inference/vision_language_multi_image.py
+26
-10
No files found.
examples/offline_inference/vision_language_multi_image.py
View file @
3336c8cf
...
@@ -593,21 +593,21 @@ def load_qwen_vl_chat(question: str, image_urls: list[str]) -> ModelRequestData:
...
@@ -593,21 +593,21 @@ def load_qwen_vl_chat(question: str, image_urls: list[str]) -> ModelRequestData:
def
load_qwen2_vl
(
question
:
str
,
image_urls
:
list
[
str
])
->
ModelRequestData
:
def
load_qwen2_vl
(
question
:
str
,
image_urls
:
list
[
str
])
->
ModelRequestData
:
try
:
try
:
from
qwen_vl_utils
import
process_vision_info
from
qwen_vl_utils
import
smart_resize
except
ModuleNotFoundError
:
except
ModuleNotFoundError
:
print
(
print
(
"WARNING: `qwen-vl-utils` not installed, input images will not "
"WARNING: `qwen-vl-utils` not installed, input images will not "
"be automatically resized. You can enable this functionality by "
"be automatically resized. You can enable this functionality by "
"`pip install qwen-vl-utils`."
"`pip install qwen-vl-utils`."
)
)
process_vision_info
=
None
smart_resize
=
None
model_name
=
"Qwen/Qwen2-VL-7B-Instruct"
model_name
=
"Qwen/Qwen2-VL-7B-Instruct"
# Tested on L40
# Tested on L40
engine_args
=
EngineArgs
(
engine_args
=
EngineArgs
(
model
=
model_name
,
model
=
model_name
,
max_model_len
=
32768
if
process_vision_info
is
None
else
4096
,
max_model_len
=
32768
if
smart_resize
is
None
else
4096
,
max_num_seqs
=
5
,
max_num_seqs
=
5
,
limit_mm_per_prompt
=
{
"image"
:
len
(
image_urls
)},
limit_mm_per_prompt
=
{
"image"
:
len
(
image_urls
)},
)
)
...
@@ -630,10 +630,18 @@ def load_qwen2_vl(question: str, image_urls: list[str]) -> ModelRequestData:
...
@@ -630,10 +630,18 @@ def load_qwen2_vl(question: str, image_urls: list[str]) -> ModelRequestData:
messages
,
tokenize
=
False
,
add_generation_prompt
=
True
messages
,
tokenize
=
False
,
add_generation_prompt
=
True
)
)
if
process_vision_info
is
None
:
if
smart_resize
is
None
:
image_data
=
[
fetch_image
(
url
)
for
url
in
image_urls
]
image_data
=
[
fetch_image
(
url
)
for
url
in
image_urls
]
else
:
else
:
image_data
,
_
=
process_vision_info
(
messages
)
def
post_process_image
(
image
:
Image
)
->
Image
:
width
,
height
=
image
.
size
resized_height
,
resized_width
=
smart_resize
(
height
,
width
,
max_pixels
=
1024
*
28
*
28
)
return
image
.
resize
((
resized_width
,
resized_height
))
image_data
=
[
post_process_image
(
fetch_image
(
url
))
for
url
in
image_urls
]
return
ModelRequestData
(
return
ModelRequestData
(
engine_args
=
engine_args
,
engine_args
=
engine_args
,
...
@@ -644,20 +652,20 @@ def load_qwen2_vl(question: str, image_urls: list[str]) -> ModelRequestData:
...
@@ -644,20 +652,20 @@ def load_qwen2_vl(question: str, image_urls: list[str]) -> ModelRequestData:
def
load_qwen2_5_vl
(
question
:
str
,
image_urls
:
list
[
str
])
->
ModelRequestData
:
def
load_qwen2_5_vl
(
question
:
str
,
image_urls
:
list
[
str
])
->
ModelRequestData
:
try
:
try
:
from
qwen_vl_utils
import
process_vision_info
from
qwen_vl_utils
import
smart_resize
except
ModuleNotFoundError
:
except
ModuleNotFoundError
:
print
(
print
(
"WARNING: `qwen-vl-utils` not installed, input images will not "
"WARNING: `qwen-vl-utils` not installed, input images will not "
"be automatically resized. You can enable this functionality by "
"be automatically resized. You can enable this functionality by "
"`pip install qwen-vl-utils`."
"`pip install qwen-vl-utils`."
)
)
process_vision_info
=
None
smart_resize
=
None
model_name
=
"Qwen/Qwen2.5-VL-3B-Instruct"
model_name
=
"Qwen/Qwen2.5-VL-3B-Instruct"
engine_args
=
EngineArgs
(
engine_args
=
EngineArgs
(
model
=
model_name
,
model
=
model_name
,
max_model_len
=
32768
if
process_vision_info
is
None
else
4096
,
max_model_len
=
32768
if
smart_resize
is
None
else
4096
,
max_num_seqs
=
5
,
max_num_seqs
=
5
,
limit_mm_per_prompt
=
{
"image"
:
len
(
image_urls
)},
limit_mm_per_prompt
=
{
"image"
:
len
(
image_urls
)},
)
)
...
@@ -680,10 +688,18 @@ def load_qwen2_5_vl(question: str, image_urls: list[str]) -> ModelRequestData:
...
@@ -680,10 +688,18 @@ def load_qwen2_5_vl(question: str, image_urls: list[str]) -> ModelRequestData:
messages
,
tokenize
=
False
,
add_generation_prompt
=
True
messages
,
tokenize
=
False
,
add_generation_prompt
=
True
)
)
if
process_vision_info
is
None
:
if
smart_resize
is
None
:
image_data
=
[
fetch_image
(
url
)
for
url
in
image_urls
]
image_data
=
[
fetch_image
(
url
)
for
url
in
image_urls
]
else
:
else
:
image_data
,
_
=
process_vision_info
(
messages
,
return_video_kwargs
=
False
)
def
post_process_image
(
image
:
Image
)
->
Image
:
width
,
height
=
image
.
size
resized_height
,
resized_width
=
smart_resize
(
height
,
width
,
max_pixels
=
1024
*
28
*
28
)
return
image
.
resize
((
resized_width
,
resized_height
))
image_data
=
[
post_process_image
(
fetch_image
(
url
))
for
url
in
image_urls
]
return
ModelRequestData
(
return
ModelRequestData
(
engine_args
=
engine_args
,
engine_args
=
engine_args
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment