"vscode:/vscode.git/clone" did not exist on "a425dc256e4c2f76f98be136cd898b43f02e6a32"
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: ...@@ -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]): ...@@ -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(",")
]) ])
......
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