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
52683ccb
Unverified
Commit
52683ccb
authored
Feb 03, 2026
by
Cyrus Leung
Committed by
GitHub
Feb 03, 2026
Browse files
[Misc] Update default image format of `encode_base64` (#33656)
Signed-off-by:
DarkLight1337
<
tlleungac@connect.ust.hk
>
parent
e346e2d0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
18 deletions
+4
-18
vllm/multimodal/media/image.py
vllm/multimodal/media/image.py
+3
-14
vllm/multimodal/utils.py
vllm/multimodal/utils.py
+1
-4
No files found.
vllm/multimodal/media/image.py
View file @
52683ccb
...
...
@@ -8,13 +8,11 @@ import pybase64
import
torch
from
PIL
import
Image
from
vllm.
logger
import
init_logger
from
vllm.
utils.serial_utils
import
tensor2base64
from
..image
import
convert_image_mode
,
rgba_to_rgb
from
.base
import
MediaIO
,
MediaWithBytes
logger
=
init_logger
(
__file__
)
class
ImageMediaIO
(
MediaIO
[
Image
.
Image
]):
def
__init__
(
self
,
image_mode
:
str
=
"RGB"
,
**
kwargs
)
->
None
:
...
...
@@ -77,17 +75,8 @@ class ImageMediaIO(MediaIO[Image.Image]):
self
,
media
:
Image
.
Image
,
*
,
image_format
:
str
|
None
=
None
,
image_format
:
str
=
"PNG"
,
)
->
str
:
if
image_format
is
None
:
logger
.
warning_once
(
"The default format of `ImageMediaIO.encode_base64` will be changed "
'from "JPEG" to "PNG" in v0.15 to avoid lossy compression. '
"To continue using the old default, "
'pass `format="JPEG"` explicitly to silence this warning.'
)
image_format
=
"JPEG"
image
=
media
with
BytesIO
()
as
buffer
:
...
...
@@ -121,4 +110,4 @@ class ImageEmbeddingMediaIO(MediaIO[torch.Tensor]):
return
tensor
.
to_dense
()
def
encode_base64
(
self
,
media
:
torch
.
Tensor
)
->
str
:
return
pybase64
.
b64encode
(
media
.
numpy
()).
decode
(
"utf-8"
)
return
tensor2base64
(
media
)
vllm/multimodal/utils.py
View file @
52683ccb
...
...
@@ -11,7 +11,6 @@ import numpy as np
import
numpy.typing
as
npt
from
PIL
import
Image
from
vllm.logger
import
init_logger
from
vllm.utils.import_utils
import
LazyLoader
from
.inputs
import
(
...
...
@@ -27,8 +26,6 @@ if TYPE_CHECKING:
else
:
torch
=
LazyLoader
(
"torch"
,
globals
(),
"torch"
)
logger
=
init_logger
(
__name__
)
def
__getattr__
(
name
:
str
):
if
name
==
"MEDIA_CONNECTOR_REGISTRY"
:
...
...
@@ -74,7 +71,7 @@ def encode_image_base64(
image
:
Image
.
Image
,
*
,
image_mode
:
str
=
"RGB"
,
format
:
str
|
None
=
None
,
format
:
str
=
"PNG"
,
)
->
str
:
"""
Encode a pillow image to base64 format.
...
...
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