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, 00:00 UTC
[Misc] Update default image format of `encode_base64` (#33656)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Cyrus Leung committed
Feb 3, 2026 at 19:13 UTC
52683ccbe194688b5c2a1a8ff6b6d9a060a2b2e7
2 files changed
+4
-18
vllm/multimodal/media/image.py
+3
-14
@@ -8,13 +8,11 @@ import pybase64
8
import torch
9
from PIL import Image
10
11
-from vllm.logger import init_logger
11
+from vllm.utils.serial_utils import tensor2base64
12
13
from ..image import convert_image_mode, rgba_to_rgb
14
from .base import MediaIO, MediaWithBytes
15
16
-logger = init_logger(__file__)
17
-
16
17
class ImageMediaIO(MediaIO[Image.Image]):
18
def __init__(self, image_mode: str = "RGB", **kwargs) -> None:
@@ -77,17 +75,8 @@ class ImageMediaIO(MediaIO[Image.Image]):
75
self,
76
media: Image.Image,
77
*,
80
- image_format: str | None = None,
78
+ image_format: str = "PNG",
79
) -> str:
82
- if image_format is None:
83
- logger.warning_once(
84
- "The default format of `ImageMediaIO.encode_base64` will be changed "
85
- 'from "JPEG" to "PNG" in v0.15 to avoid lossy compression. '
86
- "To continue using the old default, "
87
- 'pass `format="JPEG"` explicitly to silence this warning.'
88
- )
89
- image_format = "JPEG"
90
-
80
image = media
81
82
with BytesIO() as buffer:
@@ -121,4 +110,4 @@ class ImageEmbeddingMediaIO(MediaIO[torch.Tensor]):
110
return tensor.to_dense()
111
112
def encode_base64(self, media: torch.Tensor) -> str:
124
- return pybase64.b64encode(media.numpy()).decode("utf-8")
113
+ return tensor2base64(media)
vllm/multimodal/utils.py
+1
-4
@@ -11,7 +11,6 @@ import numpy as np
11
import numpy.typing as npt
12
from PIL import Image
13
14
-from vllm.logger import init_logger
14
from vllm.utils.import_utils import LazyLoader
15
16
from .inputs import (
@@ -27,8 +26,6 @@ if TYPE_CHECKING:
26
else:
27
torch = LazyLoader("torch", globals(), "torch")
28
30
-logger = init_logger(__name__)
31
-
29
30
def __getattr__(name: str):
31
if name == "MEDIA_CONNECTOR_REGISTRY":
@@ -74,7 +71,7 @@ def encode_image_base64(
71
image: Image.Image,
72
*,
73
image_mode: str = "RGB",
77
- format: str | None = None,
74
+ format: str = "PNG",
75
) -> str:
76
"""
77
Encode a pillow image to base64 format.