Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/safeds/data/image/containers/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from safeds.exceptions import IllegalFormatError

if TYPE_CHECKING:
from numpy import dtype, ndarray
from torch import Tensor


Expand Down Expand Up @@ -174,25 +173,6 @@ def __sizeof__(self) -> int:
"""
return sys.getsizeof(self._image_tensor) + self._image_tensor.element_size() * self._image_tensor.nelement()

def __array__(self, numpy_dtype: str | dtype | None = None) -> ndarray:
"""
Return the image as a numpy array.

Returns
-------
numpy_array:
The image as numpy array.
"""
from numpy import uint8

return (
self._image_tensor.permute(1, 2, 0)
.detach()
.cpu()
.numpy()
.astype(uint8 if numpy_dtype is None else numpy_dtype)
)

def _repr_jpeg_(self) -> bytes | None:
"""
Return a JPEG image as bytes.
Expand Down