@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 9df152bbf6
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 9, 06:15 UTC

[Misc] Algin Qwen3-VL-embedding image example outputs with HF repo example (#33419)

Signed-off-by: Isotr0py <mozf@mail2.sysu.edu.cn>

Isotr0py committed Jan 31, 2026 at 11:36 UTC 9df152bbf6c27db737636960ae791546d65269fc
1 file changed +28 -1
examples/pooling/embed/vision_embedding_offline.py
+28 -1
@@ -12,6 +12,8 @@ on HuggingFace model repository.
12 import argparse
13 from dataclasses import asdict
14
15 +from PIL.Image import Image
16 +
17 from vllm import LLM, EngineArgs
18 from vllm.multimodal.utils import fetch_image
19
@@ -20,17 +22,42 @@ text = "A cat standing in the snow."
22 multi_modal_data = {"image": fetch_image(image_url)}
23
24
23 -def print_embeddings(embeds):
25 +def print_embeddings(embeds: list[float]):
26 embeds_trimmed = (str(embeds[:4])[:-1] + ", ...]") if len(embeds) > 4 else embeds
27 print(f"Embeddings: {embeds_trimmed} (size={len(embeds)})")
28
29
30 def run_qwen3_vl():
31 + try:
32 + from qwen_vl_utils import smart_resize
33 + except ModuleNotFoundError:
34 + print(
35 + "WARNING: `qwen-vl-utils` not installed, input images will not "
36 + "be automatically resized. This can cause different results "
37 + "comparing with HF repo's example. "
38 + "You can enable this functionality by `pip install qwen-vl-utils`."
39 + )
40 + smart_resize = None
41 +
42 + if smart_resize is not None:
43 +
44 + def post_process_image(image: Image) -> Image:
45 + width, height = image.size
46 + resized_height, resized_width = smart_resize(
47 + height,
48 + width,
49 + factor=32,
50 + )
51 + return image.resize((resized_width, resized_height))
52 +
53 + multi_modal_data["image"] = post_process_image(multi_modal_data["image"])
54 +
55 engine_args = EngineArgs(
56 model="Qwen/Qwen3-VL-Embedding-2B",
57 runner="pooling",
58 max_model_len=8192,
59 limit_mm_per_prompt={"image": 1},
60 + mm_processor_kwargs={"do_resize": False} if smart_resize is not None else None,
61 )
62 default_instruction = "Represent the user's input."
63 image_placeholder = "<|vision_start|><|image_pad|><|vision_end|>"