Skip to content

Commit 6071e98

Browse files
authored
[Core][Multimodal] Convert PIL Image to array without data copy when hashing (#18682)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
1 parent 57fd13a commit 6071e98

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

vllm/multimodal/hasher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def serialize_item(cls, obj: object) -> bytes:
3636
return np.array(obj).tobytes()
3737

3838
if isinstance(obj, Image.Image):
39-
return cls.item_to_bytes("image",
40-
np.array(convert_image_mode(obj, "RGBA")))
39+
return cls.item_to_bytes(
40+
"image", np.asarray(convert_image_mode(obj, "RGBA")))
4141
if isinstance(obj, torch.Tensor):
4242
return cls.item_to_bytes("tensor", obj.numpy())
4343
if isinstance(obj, np.ndarray):

vllm/multimodal/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def load_base64(self, media_type: str, data: str) -> npt.NDArray:
164164
)
165165

166166
return np.stack([
167-
np.array(load_frame(frame_data))
167+
np.asarray(load_frame(frame_data))
168168
for frame_data in data.split(",")
169169
])
170170

0 commit comments

Comments
 (0)