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 7, 12:45 UTC
custom dataset img support base64 (#35280)
Signed-off-by: xjx <493337577@qq.com>
flutist committed
Feb 28, 2026 at 19:49 UTC
c68e69f1449cc6d84f43137fcc36c142de1c8fd3
1 file changed
+8
-6
vllm/benchmarks/datasets.py
+8
-6
@@ -305,9 +305,11 @@ def process_image(image: Any) -> Mapping[str, Any]:
305
a JPEG in memory. - Encodes the JPEG data as a base64 string. - Returns
306
a dictionary with the image as a base64 data URL.
307
308
- 3. String input: - Treats the string as a URL or local file path. -
309
- Prepends "file://" if the string doesn't start with "http://" or
310
- "file://". - Returns a dictionary with the image URL.
308
+ 3. String input: - Treats the string as a URL, local file path, or base64
309
+ encoded data. - If string starts with "data:image/", treats as base64.
310
+ - If string starts with "http://", "https://", or "file://", treats as URL.
311
+ - Otherwise treats as local file path and prepends "file://".
312
+ - Returns a dictionary with the image URL or base64 data.
313
314
Raises:
315
ValueError: If the input is not a supported type.
@@ -327,14 +329,14 @@ def process_image(image: Any) -> Mapping[str, Any]:
329
if isinstance(image, str):
330
image_url = (
331
image
330
- if image.startswith(("http://", "https://", "file://"))
332
+ if image.startswith(("http://", "https://", "file://", "data:image/"))
333
else f"file://{image}"
334
)
335
return {"type": "image_url", "image_url": {"url": image_url}}
336
337
raise ValueError(
336
- f"Invalid image input {image}. Must be a PIL.Image.Image"
337
- " or str or dictionary with raw image bytes."
338
+ f"Invalid image input {image}. Must be a PIL.Image.Image, "
339
+ "str (URL, file path, or base64 data URL), or dictionary with raw image bytes."
340
)
341
342