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
3443aaf8
Unverified
Commit
3443aaf8
authored
Jun 25, 2025
by
h-avsha
Committed by
GitHub
Jun 24, 2025
Browse files
Move to a faster base64 implementation (#19984)
Signed-off-by:
h-avsha
<
avshalom.manevich@hcompany.ai
>
parent
2273ec32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
requirements/common.txt
requirements/common.txt
+1
-0
vllm/multimodal/image.py
vllm/multimodal/image.py
+5
-5
No files found.
requirements/common.txt
View file @
3443aaf8
...
@@ -44,3 +44,4 @@ watchfiles # required for http server to monitor the updates of TLS files
...
@@ -44,3 +44,4 @@ watchfiles # required for http server to monitor the updates of TLS files
python-json-logger # Used by logging as per examples/others/logging_configuration.md
python-json-logger # Used by logging as per examples/others/logging_configuration.md
scipy # Required for phi-4-multimodal-instruct
scipy # Required for phi-4-multimodal-instruct
ninja # Required for xgrammar, rocm, tpu, xpu
ninja # Required for xgrammar, rocm, tpu, xpu
pybase64 # fast base64 implementation
vllm/multimodal/image.py
View file @
3443aaf8
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
base64
from
io
import
BytesIO
from
io
import
BytesIO
from
pathlib
import
Path
from
pathlib
import
Path
import
pybase64
import
torch
import
torch
from
PIL
import
Image
from
PIL
import
Image
...
@@ -55,7 +55,7 @@ class ImageMediaIO(MediaIO[Image.Image]):
...
@@ -55,7 +55,7 @@ class ImageMediaIO(MediaIO[Image.Image]):
return
convert_image_mode
(
image
,
self
.
image_mode
)
return
convert_image_mode
(
image
,
self
.
image_mode
)
def
load_base64
(
self
,
media_type
:
str
,
data
:
str
)
->
Image
.
Image
:
def
load_base64
(
self
,
media_type
:
str
,
data
:
str
)
->
Image
.
Image
:
return
self
.
load_bytes
(
base64
.
b64decode
(
data
))
return
self
.
load_bytes
(
py
base64
.
b64decode
(
data
,
validate
=
True
))
def
load_file
(
self
,
filepath
:
Path
)
->
Image
.
Image
:
def
load_file
(
self
,
filepath
:
Path
)
->
Image
.
Image
:
image
=
Image
.
open
(
filepath
)
image
=
Image
.
open
(
filepath
)
...
@@ -75,7 +75,7 @@ class ImageMediaIO(MediaIO[Image.Image]):
...
@@ -75,7 +75,7 @@ class ImageMediaIO(MediaIO[Image.Image]):
image
.
save
(
buffer
,
image_format
)
image
.
save
(
buffer
,
image_format
)
data
=
buffer
.
getvalue
()
data
=
buffer
.
getvalue
()
return
base64
.
b64encode
(
data
).
decode
(
'utf-8'
)
return
py
base64
.
b64encode
(
data
).
decode
(
'utf-8'
)
class
ImageEmbeddingMediaIO
(
MediaIO
[
torch
.
Tensor
]):
class
ImageEmbeddingMediaIO
(
MediaIO
[
torch
.
Tensor
]):
...
@@ -88,10 +88,10 @@ class ImageEmbeddingMediaIO(MediaIO[torch.Tensor]):
...
@@ -88,10 +88,10 @@ class ImageEmbeddingMediaIO(MediaIO[torch.Tensor]):
return
torch
.
load
(
buffer
,
weights_only
=
True
)
return
torch
.
load
(
buffer
,
weights_only
=
True
)
def
load_base64
(
self
,
media_type
:
str
,
data
:
str
)
->
torch
.
Tensor
:
def
load_base64
(
self
,
media_type
:
str
,
data
:
str
)
->
torch
.
Tensor
:
return
self
.
load_bytes
(
base64
.
b64decode
(
data
))
return
self
.
load_bytes
(
py
base64
.
b64decode
(
data
,
validate
=
True
))
def
load_file
(
self
,
filepath
:
Path
)
->
torch
.
Tensor
:
def
load_file
(
self
,
filepath
:
Path
)
->
torch
.
Tensor
:
return
torch
.
load
(
filepath
,
weights_only
=
True
)
return
torch
.
load
(
filepath
,
weights_only
=
True
)
def
encode_base64
(
self
,
media
:
torch
.
Tensor
)
->
str
:
def
encode_base64
(
self
,
media
:
torch
.
Tensor
)
->
str
:
return
base64
.
b64encode
(
media
.
numpy
()).
decode
(
'utf-8'
)
return
py
base64
.
b64encode
(
media
.
numpy
()).
decode
(
'utf-8'
)
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