diff --git a/src/safeds/data/image/containers/_image.py b/src/safeds/data/image/containers/_image.py index 867242d27..1324f4eb1 100644 --- a/src/safeds/data/image/containers/_image.py +++ b/src/safeds/data/image/containers/_image.py @@ -1,6 +1,7 @@ from __future__ import annotations import io +import os.path import sys import warnings from pathlib import Path @@ -76,12 +77,14 @@ def from_file(path: str | Path) -> Image: FileNotFoundError If the file of the path cannot be found """ - from PIL.Image import open as pil_image_open - from torchvision.transforms.functional import pil_to_tensor + from torchvision.io import read_image _init_default_device() - return Image(image_tensor=pil_to_tensor(pil_image_open(path))) + if not os.path.isfile(path): + raise FileNotFoundError(f"No such file or directory: '{path}'") + + return Image(image_tensor=read_image(str(path)).to(_get_device())) @staticmethod def from_bytes(data: bytes) -> Image: diff --git a/src/safeds/data/image/containers/_image_list.py b/src/safeds/data/image/containers/_image_list.py index fa10c5cac..a69dfefa4 100644 --- a/src/safeds/data/image/containers/_image_list.py +++ b/src/safeds/data/image/containers/_image_list.py @@ -3,12 +3,15 @@ import io import math import os +import random from abc import ABCMeta, abstractmethod from pathlib import Path +from threading import Thread from typing import TYPE_CHECKING, Literal, overload from safeds._config import _init_default_device from safeds.data.image.containers._image import Image +from safeds.exceptions import OutOfBoundsError, ClosedBound if TYPE_CHECKING: from collections.abc import Sequence @@ -87,12 +90,26 @@ def from_files(path: str | Path | Sequence[str | Path]) -> ImageList: ... @staticmethod @overload - def from_files(path: str | Path | Sequence[str | Path], return_filenames: Literal[False]) -> ImageList: ... + def from_files(path: str | Path | Sequence[str | Path], *, load_percentage: float) -> ImageList: ... + + @staticmethod + @overload + def from_files(path: str | Path | Sequence[str | Path], *, return_filenames: Literal[False]) -> ImageList: ... + + @staticmethod + @overload + def from_files( + path: str | Path | Sequence[str | Path], + *, + return_filenames: Literal[False], + load_percentage: float, + ) -> ImageList: ... @staticmethod @overload def from_files( path: str | Path | Sequence[str | Path], + *, return_filenames: Literal[True], ) -> tuple[ImageList, list[str]]: ... @@ -100,13 +117,34 @@ def from_files( @overload def from_files( path: str | Path | Sequence[str | Path], + *, + return_filenames: Literal[True], + load_percentage: float, + ) -> tuple[ImageList, list[str]]: ... + + @staticmethod + @overload + def from_files( + path: str | Path | Sequence[str | Path], + *, return_filenames: bool, ) -> ImageList | tuple[ImageList, list[str]]: ... @staticmethod + @overload def from_files( path: str | Path | Sequence[str | Path], + *, + return_filenames: bool, + load_percentage: float, + ) -> ImageList | tuple[ImageList, list[str]]: ... + + @staticmethod + def from_files( + path: str | Path | Sequence[str | Path], + *, return_filenames: bool = False, + load_percentage: float = 1.0, ) -> ImageList | tuple[ImageList, list[str]]: """ Create an ImageList from a directory or a list of files. @@ -119,6 +157,8 @@ def from_files( the path to the directory or a list of files return_filenames: if True the output will be a tuple which contains a list of the filenames in order of the images + load_percentage: + the percentage of the given data being loaded. If below 1 the files will be shuffled before loading Returns ------- @@ -129,9 +169,10 @@ def from_files( ------ FileNotFoundError If the directory or one of the files of the path cannot be found + OutOfBoundsError + If load_percentage is not between 0 and 1 """ from PIL.Image import open as pil_image_open - from torchvision.transforms.v2.functional import pil_to_tensor _init_default_device() @@ -139,12 +180,15 @@ def from_files( from safeds.data.image.containers._multi_size_image_list import _MultiSizeImageList from safeds.data.image.containers._single_size_image_list import _SingleSizeImageList + if load_percentage < 0 or load_percentage > 1: + raise OutOfBoundsError( + load_percentage, name="load_percentage", lower_bound=ClosedBound(0), upper_bound=ClosedBound(1) + ) + if isinstance(path, list) and len(path) == 0: return _EmptyImageList() - image_tensors = [] file_names = [] - fixed_size = True path_list: list[str | Path] if isinstance(path, Path | str): @@ -155,30 +199,139 @@ def from_files( p = Path(path_list.pop(0)) if p.is_dir(): path_list += sorted([p / name for name in os.listdir(p)]) - else: - image_tensors.append(pil_to_tensor(pil_image_open(p))) + elif p.is_file(): file_names.append(str(p)) - if fixed_size and ( - image_tensors[0].size(dim=2) != image_tensors[-1].size(dim=2) - or image_tensors[0].size(dim=1) != image_tensors[-1].size(dim=1) - ): - fixed_size = False + else: + raise FileNotFoundError(f"No such file or directory: '{path}'") - if len(image_tensors) == 0: - return _EmptyImageList() + if load_percentage < 1: + random.shuffle(file_names) + file_names = file_names[: max(round(len(file_names) * load_percentage), 1) if load_percentage > 0 else 0] - indices = list(range(len(image_tensors))) + num_of_files = len(file_names) - if fixed_size: - image_list = _SingleSizeImageList._create_image_list(image_tensors, indices) + if num_of_files == 0: + return _EmptyImageList() + + image_sizes: dict[tuple[int, int], dict[int, list[str]]] = {} + image_indices: dict[tuple[int, int], dict[int, list[int]]] = {} + image_count: dict[tuple[int, int], int] = {} + max_channel = -1 + + for i, filename in enumerate(file_names): + im = pil_image_open(filename) + im_channel = len(im.getbands()) + im_size = (im.width, im.height) + if im_channel > max_channel: + max_channel = im_channel + if im_size not in image_sizes: + image_sizes[im_size] = {im_channel: [filename]} + image_indices[im_size] = {im_channel: [i]} + image_count[im_size] = 1 + elif im_channel not in image_sizes[im_size]: + image_sizes[im_size][im_channel] = [filename] + image_indices[im_size][im_channel] = [i] + image_count[im_size] += 1 + else: + image_sizes[im_size][im_channel].append(filename) + image_indices[im_size][im_channel].append(i) + image_count[im_size] += 1 + + num_of_threads = min(math.ceil(num_of_files / 1000), 100) + num_of_files_per_thread = math.ceil(num_of_files / num_of_threads) + + single_sized_image_lists = [] + thread_packages = [] + for size, image_files in image_sizes.items(): + im_list, packages = _SingleSizeImageList._create_image_list_from_files( + image_files, + image_count[size], + max_channel, + size[0], + size[1], + image_indices[size], + num_of_files_per_thread, + ) + single_sized_image_lists.append(im_list._as_single_size_image_list()) + thread_packages += packages + thread_packages.sort(key=lambda x: len(x), reverse=True) + + threads: list[ImageList._FromImageThread] = [] + for thread_index in range(num_of_threads): + current_thread_workload = 0 + current_thread_packages = [] + while current_thread_workload < num_of_files_per_thread and len(thread_packages) > 0: + next_package = thread_packages.pop() + current_thread_packages.append(next_package) + current_thread_workload += len(next_package) + if thread_index == num_of_threads - 1 and len(thread_packages) > 0: + current_thread_packages += thread_packages # pragma: no cover + thread = ImageList._FromImageThread(current_thread_packages) + threads.append(thread) + thread.start() + for thread in threads: + thread.join() + + if len(single_sized_image_lists) == 1: + image_list: ImageList = single_sized_image_lists[0] else: - image_list = _MultiSizeImageList._create_image_list(image_tensors, indices) + image_list = _MultiSizeImageList._create_from_single_sized_image_lists(single_sized_image_lists) if return_filenames: return image_list, file_names else: return image_list + class _FromFileThreadPackage: + + def __init__( + self, + im_files: list[str], + im_channel: int, + to_channel: int, + im_width: int, + im_height: int, + tensor: Tensor, + start_index: int, + ) -> None: + self._im_files = im_files + self._im_channel = im_channel + self._to_channel = to_channel + self._im_width = im_width + self._im_height = im_height + self._tensor = tensor + self._start_index = start_index + + def load_files(self) -> None: + import torch + from torchvision.io import read_image + + _init_default_device() + + num_of_files = len(self._im_files) + tensor_channel = max(self._im_channel, min(self._to_channel, 3)) + for index, im in enumerate(self._im_files): + self._tensor[index + self._start_index, 0:tensor_channel] = read_image(im) + if self._to_channel == 4 and self._im_channel < 4: + torch.full( + (num_of_files, 1, self._im_height, self._im_width), + 255, + out=self._tensor[self._start_index : self._start_index + num_of_files, 3:4], + ) + + def __len__(self) -> int: + return len(self._im_files) + + class _FromImageThread(Thread): + + def __init__(self, packages: list[ImageList._FromFileThreadPackage]) -> None: + super().__init__() + self._packages = packages + + def run(self) -> None: + for pck in self._packages: + pck.load_files() + @abstractmethod def _clone(self) -> ImageList: """ diff --git a/src/safeds/data/image/containers/_multi_size_image_list.py b/src/safeds/data/image/containers/_multi_size_image_list.py index 1a1f89314..be1ca1789 100644 --- a/src/safeds/data/image/containers/_multi_size_image_list.py +++ b/src/safeds/data/image/containers/_multi_size_image_list.py @@ -45,6 +45,45 @@ def __init__(self) -> None: self._image_list_dict: dict[tuple[int, int], ImageList] = {} # {image_size: image_list} self._indices_to_image_size_dict: dict[int, tuple[int, int]] = {} # {index: image_size} + @staticmethod + def _create_from_single_sized_image_lists(single_size_image_lists: list[_SingleSizeImageList]) -> ImageList: + from safeds.data.image.containers._empty_image_list import _EmptyImageList + + if len(single_size_image_lists) == 0: + return _EmptyImageList() + elif len(single_size_image_lists) == 1: + return single_size_image_lists[0] + + different_channels: bool = False + max_channel: None | int = None + + image_list = _MultiSizeImageList() + for single_size_image_list in single_size_image_lists: + image_size = (single_size_image_list.widths[0], single_size_image_list.heights[0]) + image_list._image_list_dict[image_size] = single_size_image_list + image_list._indices_to_image_size_dict.update( + zip( + single_size_image_list._indices_to_tensor_positions.keys(), + [image_size] * len(single_size_image_list), + strict=False, + ) + ) + if max_channel is None: + max_channel = single_size_image_list.channel + elif max_channel < single_size_image_list.channel: + different_channels = True + max_channel = single_size_image_list.channel + elif max_channel > single_size_image_list.channel: + different_channels = True + + if different_channels: + for size in image_list._image_list_dict: + if max_channel is not None and image_list._image_list_dict[size].channel != max_channel: + image_list._image_list_dict[size] = image_list._image_list_dict[size].change_channel( + int(max_channel) + ) + return image_list + @staticmethod def _create_image_list(images: list[Tensor], indices: list[int]) -> ImageList: from safeds.data.image.containers._empty_image_list import _EmptyImageList diff --git a/src/safeds/data/image/containers/_single_size_image_list.py b/src/safeds/data/image/containers/_single_size_image_list.py index a7b71fd7a..ceaddbabf 100644 --- a/src/safeds/data/image/containers/_single_size_image_list.py +++ b/src/safeds/data/image/containers/_single_size_image_list.py @@ -56,10 +56,65 @@ def __init__(self) -> None: self._next_batch_index = 0 self._batch_size = 1 - self._tensor: Tensor = torch.empty(0) + self._tensor: Tensor = torch.empty([]) self._tensor_positions_to_indices: list[int] = [] # list[tensor_position] = index self._indices_to_tensor_positions: dict[int, int] = {} # {index: tensor_position} + @staticmethod + def _create_image_list_from_files( + images: dict[int, list[str]], + number_of_images: int, + max_channel: int, + width: int, + height: int, + indices: dict[int, list[int]], + max_files_per_thread_package: int, + ) -> tuple[ImageList, list[ImageList._FromFileThreadPackage]]: + import torch + + _init_default_device() + + from safeds.data.image.containers._empty_image_list import _EmptyImageList + + if len(images) == 0 or number_of_images == 0: + return _EmptyImageList(), [] + + image_list = _SingleSizeImageList() + + images_tensor = torch.empty( + number_of_images, max_channel, height, width, dtype=torch.uint8, device=_get_device() + ) + + thread_packages: list[ImageList._FromFileThreadPackage] = [] + current_thread_channel: int | None = None + current_thread_channel_files: list[str] = [] + current_thread_start_index: int = 0 + while number_of_images - current_thread_start_index > 0: + num_of_files = min(max_files_per_thread_package, number_of_images - current_thread_start_index) + while num_of_files > 0: + if current_thread_channel is None or len(current_thread_channel_files) == 0: + current_thread_channel = next(iter(images.keys())) + current_thread_channel_files = images.pop(current_thread_channel) + next_package_size = min(num_of_files, len(current_thread_channel_files)) + package = ImageList._FromFileThreadPackage( + current_thread_channel_files[:next_package_size], + current_thread_channel, + max_channel, + width, + height, + images_tensor, + current_thread_start_index, + ) + current_thread_start_index += next_package_size + num_of_files -= next_package_size + current_thread_channel_files = current_thread_channel_files[next_package_size:] + thread_packages.append(package) + + image_list._tensor = images_tensor + image_list._tensor_positions_to_indices = [i for j in indices.values() for i in j] + image_list._indices_to_tensor_positions = image_list._calc_new_indices_to_tensor_positions() + return image_list, thread_packages + @staticmethod def _create_image_list(images: list[Tensor], indices: list[int]) -> ImageList: import torch @@ -374,6 +429,8 @@ def to_images(self, indices: list[int] | None = None) -> list[Image]: return [Image(self._tensor[self._indices_to_tensor_positions[index]]) for index in indices] def change_channel(self, channel: int) -> ImageList: + if channel == self.channel: + return self image_list = self._clone_without_tensor() image_list._tensor = _SingleSizeImageList._change_channel_of_tensor(self._tensor, channel) return image_list diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cpu].png new file mode 100644 index 000000000..d61bdf2e0 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cuda].png new file mode 100644 index 000000000..d61bdf2e0 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_create_from_single_sized_image_lists[all-images-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cpu].png new file mode 100644 index 000000000..f6e27f2e7 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cuda].png new file mode 100644 index 000000000..f6e27f2e7 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cpu].png new file mode 100644 index 000000000..f6e27f2e7 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cuda].png new file mode 100644 index 000000000..f6e27f2e7 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[all-images-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cpu].png new file mode 100644 index 000000000..40477ac64 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cuda].png new file mode 100644 index 000000000..40477ac64 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cpu].png new file mode 100644 index 000000000..40477ac64 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cuda].png new file mode 100644 index 000000000..40477ac64 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[images_folder-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-jpg-grayscale-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-jpg-grayscale-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-1-channel-png-grayscale-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-1-channel-png-grayscale-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-plane-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-plane-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-jpg-white_square-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-jpg-white_square-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-3-channel-png-white_square-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-3-channel-png-white_square-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[opaque-4-channel-png-plane-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[opaque-4-channel-png-plane-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[transparent-4-channel-png-rgba-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_load_percentage[transparent-4-channel-png-rgba-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[all-images-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[all-images-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-path-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-path-cpu].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-path-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-path-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation[images_folder-path-cuda].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[images_folder-path-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cpu].png new file mode 100644 index 000000000..fc925a7c9 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cuda].png new file mode 100644 index 000000000..fc925a7c9 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cpu].png new file mode 100644 index 000000000..fc925a7c9 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cuda].png new file mode 100644 index 000000000..fc925a7c9 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-jpg-grayscale-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cpu].png new file mode 100644 index 000000000..980ad65d6 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cuda].png new file mode 100644 index 000000000..980ad65d6 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cpu].png new file mode 100644 index 000000000..980ad65d6 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cuda].png new file mode 100644 index 000000000..980ad65d6 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-1-channel-png-grayscale-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cpu].png new file mode 100644 index 000000000..479b40a8d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cuda].png new file mode 100644 index 000000000..479b40a8d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cpu].png new file mode 100644 index 000000000..479b40a8d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cuda].png new file mode 100644 index 000000000..479b40a8d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-plane-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cpu].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cuda].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cpu].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cuda].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-jpg-white_square-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cpu].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cuda].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cpu].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cuda].png new file mode 100644 index 000000000..146086a9d Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-3-channel-png-white_square-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cpu].png new file mode 100644 index 000000000..0f0a23a1f Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cuda].png new file mode 100644 index 000000000..0f0a23a1f Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cpu].png new file mode 100644 index 000000000..0f0a23a1f Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cuda].png new file mode 100644 index 000000000..0f0a23a1f Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[opaque-4-channel-png-plane-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cpu].png new file mode 100644 index 000000000..6da78e96e Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cuda].png new file mode 100644 index 000000000..6da78e96e Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cpu].png new file mode 100644 index 000000000..6da78e96e Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cuda].png new file mode 100644 index 000000000..6da78e96e Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestFromFiles.test_from_files_creation_return_filenames[transparent-4-channel-png-rgba-path-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cpu].png index e2c8c75fc..9b4489a26 100644 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cpu].png and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cuda].png index e2c8c75fc..9b4489a26 100644 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cuda].png and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestShuffleImages.test_shuffle_images[all-images-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cpu-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-all-images-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cpu-all-images].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-all-images-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cuda-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-all-images-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cuda-all-images].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-all-images-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cpu-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-planes-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cpu-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-planes-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cuda-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-planes-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-cuda-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[minimum noise-planes-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cpu].png new file mode 100644 index 000000000..27798023e Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cuda].png new file mode 100644 index 000000000..8f52164a2 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-all-images-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cpu-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cpu-all-images].png deleted file mode 100644 index edee2ecea..000000000 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cpu-all-images].png and /dev/null differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cuda-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cuda-all-images].png deleted file mode 100644 index c20a7f4bc..000000000 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cuda-all-images].png and /dev/null differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cpu-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-planes-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cpu-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-planes-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cuda-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-planes-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-cuda-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[some noise-planes-cuda].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cpu].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cpu].png new file mode 100644 index 000000000..aacc1a802 Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cpu].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cuda].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cuda].png new file mode 100644 index 000000000..bbb2517ae Binary files /dev/null and b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-all-images-cuda].png differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cpu-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cpu-all-images].png deleted file mode 100644 index 3dbf5b02e..000000000 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cpu-all-images].png and /dev/null differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cuda-all-images].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cuda-all-images].png deleted file mode 100644 index 51889a982..000000000 Binary files a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cuda-all-images].png and /dev/null differ diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cpu-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-planes-cpu].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cpu-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-planes-cpu].png diff --git a/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cuda-planes].png b/tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-planes-cuda].png similarity index 100% rename from tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-cuda-planes].png rename to tests/safeds/data/image/containers/__snapshots__/test_image_list/TestTransforms.TestAddNoise.test_should_add_noise[very noisy-planes-cuda].png diff --git a/tests/safeds/data/image/containers/test_image_list.py b/tests/safeds/data/image/containers/test_image_list.py index b936bb3cf..b456001a2 100644 --- a/tests/safeds/data/image/containers/test_image_list.py +++ b/tests/safeds/data/image/containers/test_image_list.py @@ -462,7 +462,7 @@ class TestFromFiles: *[s + "-path" for s in images_all_ids()], ], ) - def test_from_files_creation( + def test_from_files_creation_return_filenames( self, resource_path: str | Path, snapshot_png_image_list: SnapshotAssertion, device: Device ) -> None: configure_test_with_device(device) @@ -475,6 +475,38 @@ def test_from_files_creation( assert image_list == image_list_returned_filenames assert len(image_list) == len(filenames) + @pytest.mark.parametrize( + "resource_path", + [ + images_all(), + str(test_images_folder), + *images_all(), + [Path(im) for im in images_all()], + test_images_folder, + *[Path(im) for im in images_all()], + ], + ids=[ + "all-images", + "images_folder", + *images_all_ids(), + "all-images-path", + "images_folder-path", + *[s + "-path" for s in images_all_ids()], + ], + ) + def test_from_files_creation_load_percentage( + self, resource_path: str | Path, snapshot_png_image_list: SnapshotAssertion, device: Device + ) -> None: + random.seed(420) + configure_test_with_device(device) + image_list = ImageList.from_files(resolve_resource_path(resource_path)) + image_list_load_percentage = ImageList.from_files( + resolve_resource_path(resource_path), + load_percentage=0.5, + ) + assert image_list_load_percentage == snapshot_png_image_list + assert len(image_list_load_percentage) == max(round(len(image_list) * 0.5), 1) + @pytest.mark.parametrize( "resource_path", [ @@ -492,6 +524,48 @@ def test_should_raise_if_one_file_or_directory_not_found(self, resource_path: st with pytest.raises(FileNotFoundError): ImageList.from_files(resolve_resource_path(resource_path)) + @pytest.mark.parametrize( + "resource_path", + [images_all(), [plane_png_path, plane_jpg_path] * 2], + ids=["all-images", "planes"], + ) + @pytest.mark.parametrize( + "load_percentage", + [-1.0, 2.0], + ) + def test_should_raise_if_load_percentage_out_of_bounds( + self, resource_path: str | Path, load_percentage: float, device: Device + ) -> None: + configure_test_with_device(device) + with pytest.raises(OutOfBoundsError, match=rf"load_percentage \(={load_percentage}\) is not inside \[0, 1\]."): + ImageList.from_files(resolve_resource_path(resource_path), load_percentage=load_percentage) + + def test_create_from_single_sized_image_lists_one_image_list(self, device: Device) -> None: + configure_test_with_device(device) + assert isinstance( + _MultiSizeImageList()._create_from_single_sized_image_lists( + [ImageList.from_files(resolve_resource_path(plane_png_path))._as_single_size_image_list()] + ), + _SingleSizeImageList, + ) + + @pytest.mark.parametrize( + "resource_path", + [images_all()], + ids=["all-images"], + ) + def test_create_from_single_sized_image_lists( + self, resource_path: str | Path, snapshot_png_image_list: SnapshotAssertion, device: Device + ) -> None: + configure_test_with_device(device) + image_lists = ImageList.from_files(resolve_resource_path(resource_path)) + single_sized_image_lists = [] + for i, i_list in enumerate(image_lists._as_multi_size_image_list()._image_list_dict.values()): + single_sized_image_lists.append(i_list.change_channel([1, 3, 4][i % 3])._as_single_size_image_list()) + multi_sized_image_list = _MultiSizeImageList()._create_from_single_sized_image_lists(single_sized_image_lists) + assert isinstance(multi_sized_image_list, _MultiSizeImageList) + assert multi_sized_image_list == snapshot_png_image_list + @pytest.mark.parametrize("device", get_devices(), ids=get_devices_ids()) class TestToImages: @@ -786,6 +860,7 @@ def test_shuffle_images( assert len(image_list_shuffled) == len(resource_path) for index in range(len(resource_path)): assert image_list_shuffled.get_image(index) in image_list_original + assert image_list_shuffled != image_list_original assert image_list_shuffled == snapshot_png_image_list assert image_list_original is not image_list_clone assert image_list_original == image_list_clone @@ -885,13 +960,13 @@ def test_all_transform_methods( assert image_list_original == image_list_clone -@pytest.mark.parametrize( - "resource_path", - [images_all(), [plane_png_path, plane_jpg_path] * 2], - ids=["all-images", "planes"], -) @pytest.mark.parametrize("device", get_devices(), ids=get_devices_ids()) class TestTransforms: + @pytest.mark.parametrize( + "resource_path", + [images_all(), [plane_png_path, plane_jpg_path] * 2], + ids=["all-images", "planes"], + ) class TestAddNoise: @pytest.mark.parametrize( "standard_deviation", @@ -919,6 +994,20 @@ def test_should_add_noise( assert image_list_original is not image_list_clone assert image_list_original == image_list_clone + @pytest.mark.parametrize( + "channel_in", + [1, 3, 4], + ) + @pytest.mark.parametrize( + "channel_out", + [1, 3, 4], + ) + def test_change_channel_of_tensor(self, channel_in: int, channel_out: int, device: Device) -> None: + configure_test_with_device(device) + tensor = torch.ones((5, channel_in, 5, 5)) + tensor_changed_channel = _SingleSizeImageList._change_channel_of_tensor(tensor, channel_out) + assert tensor_changed_channel.size(dim=-3) == channel_out + @pytest.mark.parametrize( "resource_path", @@ -1422,6 +1511,16 @@ def test_create_image_list(self, image_list: ImageList, device: Device) -> None: configure_test_with_device(device) assert isinstance(image_list._create_image_list([], []), _EmptyImageList) + def test_create_image_list_from_files(self, device: Device) -> None: + configure_test_with_device(device) + assert isinstance( + _SingleSizeImageList()._create_image_list_from_files({}, 0, 4, 1, 1, {}, 5)[0], _EmptyImageList + ) + + def test_create_from_single_sized_image_lists(self, device: Device) -> None: + configure_test_with_device(device) + assert isinstance(_MultiSizeImageList()._create_from_single_sized_image_lists([]), _EmptyImageList) + def test_from_images(self, device: Device) -> None: configure_test_with_device(device) assert ImageList.from_images([]) == _EmptyImageList()