Skip to content

Commit

Permalink
Be explicit about PILImage.Image conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Dec 13, 2024
1 parent 231e60c commit 0d48ea8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rerun_py/rerun_sdk/rerun/archetypes/image_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@


def _to_numpy(tensor: ImageLike) -> npt.NDArray[Any]:
from PIL import Image as PILImage

# isinstance is 4x faster than catching AttributeError
if isinstance(tensor, np.ndarray):
return tensor
if isinstance(tensor, PILImage.Image):
return np.array(tensor, copy=False)

try:
# Make available to the cpu
Expand Down

0 comments on commit 0d48ea8

Please sign in to comment.