mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 06:04:59 +08:00
[Core][Multimodal] Convert PIL Image to array without data copy when hashing (#18682)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
This commit is contained in:
parent
57fd13a707
commit
6071e989df
@ -36,8 +36,8 @@ class MultiModalHasher:
|
|||||||
return np.array(obj).tobytes()
|
return np.array(obj).tobytes()
|
||||||
|
|
||||||
if isinstance(obj, Image.Image):
|
if isinstance(obj, Image.Image):
|
||||||
return cls.item_to_bytes("image",
|
return cls.item_to_bytes(
|
||||||
np.array(convert_image_mode(obj, "RGBA")))
|
"image", np.asarray(convert_image_mode(obj, "RGBA")))
|
||||||
if isinstance(obj, torch.Tensor):
|
if isinstance(obj, torch.Tensor):
|
||||||
return cls.item_to_bytes("tensor", obj.numpy())
|
return cls.item_to_bytes("tensor", obj.numpy())
|
||||||
if isinstance(obj, np.ndarray):
|
if isinstance(obj, np.ndarray):
|
||||||
|
|||||||
@ -164,7 +164,7 @@ class VideoMediaIO(MediaIO[npt.NDArray]):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return np.stack([
|
return np.stack([
|
||||||
np.array(load_frame(frame_data))
|
np.asarray(load_frame(frame_data))
|
||||||
for frame_data in data.split(",")
|
for frame_data in data.split(",")
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user