Unverified Commit 6071e989 authored by Lukas Geiger's avatar Lukas Geiger Committed by GitHub
Browse files

[Core][Multimodal] Convert PIL Image to array without data copy when hashing (#18682)


Signed-off-by: default avatarLukas Geiger <lukas.geiger94@gmail.com>
parent 57fd13a7
......@@ -36,8 +36,8 @@ class MultiModalHasher:
return np.array(obj).tobytes()
if isinstance(obj, Image.Image):
return cls.item_to_bytes("image",
np.array(convert_image_mode(obj, "RGBA")))
return cls.item_to_bytes(
"image", np.asarray(convert_image_mode(obj, "RGBA")))
if isinstance(obj, torch.Tensor):
return cls.item_to_bytes("tensor", obj.numpy())
if isinstance(obj, np.ndarray):
......
......@@ -164,7 +164,7 @@ class VideoMediaIO(MediaIO[npt.NDArray]):
)
return np.stack([
np.array(load_frame(frame_data))
np.asarray(load_frame(frame_data))
for frame_data in data.split(",")
])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment