From a1330488520aacfb14e5cdcac1739e58ef3a8e36 Mon Sep 17 00:00:00 2001 From: Samet Akcay Date: Wed, 9 Oct 2024 12:51:42 +0100 Subject: [PATCH] Remove transforms from datasets Signed-off-by: Samet Akcay --- src/anomalib/data/datasets/base/depth.py | 18 ++++-------------- src/anomalib/data/datasets/base/image.py | 8 ++------ src/anomalib/data/datasets/base/video.py | 13 +------------ src/anomalib/data/datasets/depth/folder_3d.py | 7 +------ src/anomalib/data/datasets/depth/mvtec_3d.py | 6 +----- src/anomalib/data/datasets/image/btech.py | 9 +-------- src/anomalib/data/datasets/image/folder.py | 14 ++------------ src/anomalib/data/datasets/image/kolektor.py | 6 +----- src/anomalib/data/datasets/image/mvtec.py | 9 +-------- src/anomalib/data/datasets/image/visa.py | 13 +------------ src/anomalib/data/datasets/video/avenue.py | 9 --------- .../data/datasets/video/shanghaitech.py | 5 ----- src/anomalib/data/datasets/video/ucsd_ped.py | 5 ----- src/anomalib/data/utils/synthetic.py | 10 ++++------ 14 files changed, 19 insertions(+), 113 deletions(-) diff --git a/src/anomalib/data/datasets/base/depth.py b/src/anomalib/data/datasets/base/depth.py index 56460b3a6a..cc913f3eaa 100644 --- a/src/anomalib/data/datasets/base/depth.py +++ b/src/anomalib/data/datasets/base/depth.py @@ -9,7 +9,6 @@ import torch from PIL import Image from torchvision.transforms.functional import to_tensor -from torchvision.transforms.v2 import Transform from torchvision.tv_tensors import Mask from anomalib import TaskType @@ -24,14 +23,10 @@ class AnomalibDepthDataset(AnomalibDataset, ABC): Args: task (str): Task type, either 'classification' or 'segmentation' - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. """ - def __init__(self, task: TaskType, transform: Transform | None = None) -> None: - super().__init__(task, transform) - - self.transform = transform + def __init__(self, task: TaskType) -> None: + super().__init__(task) def __getitem__(self, index: int) -> DepthItem: """Return rgb image, depth image and mask. @@ -52,9 +47,7 @@ def __getitem__(self, index: int) -> DepthItem: item = {"image_path": image_path, "depth_path": depth_path, "label": label_index} if self.task == TaskType.CLASSIFICATION: - item["image"], item["depth_image"] = ( - self.transform(image, depth_image) if self.transform else (image, depth_image) - ) + item["image"], item["depth_image"] = image, depth_image elif self.task == TaskType.SEGMENTATION: # Only Anomalous (1) images have masks in anomaly datasets # Therefore, create empty mask for Normal (0) images. @@ -63,11 +56,8 @@ def __getitem__(self, index: int) -> DepthItem: if label_index == LabelName.NORMAL else Mask(to_tensor(Image.open(mask_path)).squeeze()) ) - item["image"], item["depth_image"], item["mask"] = ( - self.transform(image, depth_image, mask) if self.transform else (image, depth_image, mask) - ) + item["image"], item["depth_image"], item["mask"] = image, depth_image, mask item["mask_path"] = mask_path - else: msg = f"Unknown task type: {self.task}" raise ValueError(msg) diff --git a/src/anomalib/data/datasets/base/image.py b/src/anomalib/data/datasets/base/image.py index 96f6d3a929..ade50c00ff 100644 --- a/src/anomalib/data/datasets/base/image.py +++ b/src/anomalib/data/datasets/base/image.py @@ -13,7 +13,6 @@ import torch from pandas import DataFrame from torch.utils.data import Dataset -from torchvision.transforms.v2 import Transform from torchvision.tv_tensors import Mask from anomalib import TaskType @@ -58,14 +57,11 @@ class AnomalibDataset(Dataset, ABC): Args: task (str): Task type, either 'classification' or 'segmentation' - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. """ - def __init__(self, task: TaskType | str, transform: Transform | None = None) -> None: + def __init__(self, task: TaskType | str) -> None: super().__init__() self.task = TaskType(task) - self.transform = transform self._samples: DataFrame | None = None self._category: str | None = None @@ -170,7 +166,7 @@ def __getitem__(self, index: int) -> DatasetItem: item = {"image_path": image_path, "gt_label": label_index} if self.task == TaskType.CLASSIFICATION: - item["image"] = self.transform(image) if self.transform else image + item["image"] = image elif self.task == TaskType.SEGMENTATION: # Only Anomalous (1) images have masks in anomaly datasets # Therefore, create empty mask for Normal (0) images. diff --git a/src/anomalib/data/datasets/base/video.py b/src/anomalib/data/datasets/base/video.py index 3ba8f2fd83..5ab1193d7c 100644 --- a/src/anomalib/data/datasets/base/video.py +++ b/src/anomalib/data/datasets/base/video.py @@ -9,9 +9,7 @@ import torch from pandas import DataFrame -from torchvision.transforms.v2 import Transform from torchvision.transforms.v2.functional import to_dtype, to_dtype_video -from torchvision.tv_tensors import Mask from anomalib import TaskType from anomalib.data.dataclasses import VideoBatch, VideoItem @@ -39,8 +37,6 @@ class AnomalibVideoDataset(AnomalibDataset, ABC): task (str): Task type, either 'classification' or 'segmentation' clip_length_in_frames (int): Number of video frames in each clip. frames_between_clips (int): Number of frames between each consecutive video clip. - transform (Transform, optional): Transforms that should be applied to the input clips. - Defaults to ``None``. target_frame (VideoTargetFrame): Specifies the target frame in the video clip, used for ground truth retrieval. Defaults to ``VideoTargetFrame.LAST``. """ @@ -50,14 +46,12 @@ def __init__( task: TaskType, clip_length_in_frames: int, frames_between_clips: int, - transform: Transform | None = None, target_frame: VideoTargetFrame = VideoTargetFrame.LAST, ) -> None: - super().__init__(task, transform) + super().__init__(task) self.clip_length_in_frames = clip_length_in_frames self.frames_between_clips = frames_between_clips - self.transform = transform self.indexer: ClipsIndexer | None = None self.indexer_cls: Callable | None = None @@ -153,13 +147,8 @@ def __getitem__(self, index: int) -> VideoItem: # include the untransformed image for visualization item.original_image = to_dtype(item.image, torch.uint8, scale=True) - # apply transforms if item.gt_mask is not None: - if self.transform: - item.image, item.gt_mask = self.transform(item.image, Mask(item.gt_mask)) item.gt_label = torch.Tensor([1 in frame for frame in item.gt_mask]).int().squeeze(0) - elif self.transform: - item.image = self.transform(item.image) # squeeze temporal dimensions in case clip length is 1 item.image = item.image.squeeze(0) diff --git a/src/anomalib/data/datasets/depth/folder_3d.py b/src/anomalib/data/datasets/depth/folder_3d.py index 9ec78487b3..752727e1c6 100644 --- a/src/anomalib/data/datasets/depth/folder_3d.py +++ b/src/anomalib/data/datasets/depth/folder_3d.py @@ -9,7 +9,6 @@ from pathlib import Path from pandas import DataFrame, isna -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.depth import AnomalibDepthDataset @@ -24,7 +23,6 @@ class Folder3DDataset(AnomalibDepthDataset): Args: name (str): Name of the dataset. task (TaskType): Task type. (``classification``, ``detection`` or ``segmentation``). - transform (Transform): Transforms that should be applied to the input images. normal_dir (str | Path): Path to the directory containing normal images. root (str | Path | None): Root folder of the dataset. Defaults to ``None``. @@ -45,8 +43,6 @@ class Folder3DDataset(AnomalibDepthDataset): normal_test_depth_dir (str | Path | None, optional): Path to the directory containing normal depth images for the test dataset. Normal test images will be a split of `normal_dir` if `None`. Defaults to ``None``. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split (str | Split | None): Fixed subset split that follows from folder structure on file system. Choose from [Split.FULL, Split.TRAIN, Split.TEST] Defaults to ``None``. @@ -70,11 +66,10 @@ def __init__( normal_depth_dir: str | Path | None = None, abnormal_depth_dir: str | Path | None = None, normal_test_depth_dir: str | Path | None = None, - transform: Transform | None = None, split: str | Split | None = None, extensions: tuple[str, ...] | None = None, ) -> None: - super().__init__(task, transform) + super().__init__(task) self._name = name self.split = split diff --git a/src/anomalib/data/datasets/depth/mvtec_3d.py b/src/anomalib/data/datasets/depth/mvtec_3d.py index de6d326a4a..82ef991a96 100644 --- a/src/anomalib/data/datasets/depth/mvtec_3d.py +++ b/src/anomalib/data/datasets/depth/mvtec_3d.py @@ -23,7 +23,6 @@ from pathlib import Path from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.depth import AnomalibDepthDataset @@ -43,8 +42,6 @@ class MVTec3DDataset(AnomalibDepthDataset): Defaults to ``"./datasets/MVTec3D"``. category (str): Sub-category of the dataset, e.g. 'bagel' Defaults to ``"bagel"``. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split (str | Split | None): Split of the dataset, usually Split.TRAIN or Split.TEST Defaults to ``None``. """ @@ -54,10 +51,9 @@ def __init__( task: TaskType, root: Path | str = "./datasets/MVTec3D", category: str = "bagel", - transform: Transform | None = None, split: str | Split | None = None, ) -> None: - super().__init__(task=task, transform=transform) + super().__init__(task) self.root_category = Path(root) / Path(category) self.split = split diff --git a/src/anomalib/data/datasets/image/btech.py b/src/anomalib/data/datasets/image/btech.py index 412097c912..f51c5a4669 100644 --- a/src/anomalib/data/datasets/image/btech.py +++ b/src/anomalib/data/datasets/image/btech.py @@ -13,7 +13,6 @@ import pandas as pd from pandas.core.frame import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.image import AnomalibDataset @@ -28,19 +27,14 @@ class BTechDataset(AnomalibDataset): Args: root: Path to the BTech dataset category: Name of the BTech category. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split: 'train', 'val' or 'test' task: ``classification``, ``detection`` or ``segmentation`` create_validation_set: Create a validation subset in addition to the train and test subsets Examples: >>> from anomalib.data.image.btech import BTechDataset - >>> from anomalib.data.utils.transforms import get_transforms - >>> transform = get_transforms(image_size=256) >>> dataset = BTechDataset( ... task="classification", - ... transform=transform, ... root='./datasets/BTech', ... category='01', ... ) @@ -69,11 +63,10 @@ def __init__( self, root: str | Path, category: str, - transform: Transform | None = None, split: str | Split | None = None, task: TaskType | str = TaskType.SEGMENTATION, ) -> None: - super().__init__(task, transform) + super().__init__(task) self.root_category = Path(root) / category self.split = split diff --git a/src/anomalib/data/datasets/image/folder.py b/src/anomalib/data/datasets/image/folder.py index 48415c0867..01e1986414 100644 --- a/src/anomalib/data/datasets/image/folder.py +++ b/src/anomalib/data/datasets/image/folder.py @@ -10,7 +10,6 @@ from pathlib import Path from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.image import AnomalibDataset @@ -27,8 +26,6 @@ class FolderDataset(AnomalibDataset): Args: name (str): Name of the dataset. This is used to name the datamodule, especially when logging/saving. task (TaskType): Task type. (``classification``, ``detection`` or ``segmentation``). - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. normal_dir (str | Path | Sequence): Path to the directory containing normal images. root (str | Path | None): Root folder of the dataset. Defaults to ``None``. @@ -52,12 +49,7 @@ class FolderDataset(AnomalibDataset): Examples: Assume that we would like to use this ``FolderDataset`` to create a dataset from a folder for a classification - task. We could first create the transforms, - - >>> from anomalib.data.utils import InputNormalizationMethod, get_transforms - >>> transform = get_transforms(image_size=256, normalization=InputNormalizationMethod.NONE) - - We could then create the dataset as follows, + task. .. code-block:: python @@ -65,7 +57,6 @@ class FolderDataset(AnomalibDataset): normal_dir=dataset_root / "good", abnormal_dir=dataset_root / "crack", split="train", - transform=transform, task=TaskType.CLASSIFICATION, ) @@ -76,7 +67,6 @@ def __init__( name: str, task: TaskType, normal_dir: str | Path | Sequence[str | Path], - transform: Transform | None = None, root: str | Path | None = None, abnormal_dir: str | Path | Sequence[str | Path] | None = None, normal_test_dir: str | Path | Sequence[str | Path] | None = None, @@ -84,7 +74,7 @@ def __init__( split: str | Split | None = None, extensions: tuple[str, ...] | None = None, ) -> None: - super().__init__(task, transform) + super().__init__(task) self._name = name self.split = split diff --git a/src/anomalib/data/datasets/image/kolektor.py b/src/anomalib/data/datasets/image/kolektor.py index 39e9380a03..63a9feed36 100644 --- a/src/anomalib/data/datasets/image/kolektor.py +++ b/src/anomalib/data/datasets/image/kolektor.py @@ -23,7 +23,6 @@ from cv2 import imread from pandas import DataFrame from sklearn.model_selection import train_test_split -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets import AnomalibDataset @@ -38,8 +37,6 @@ class KolektorDataset(AnomalibDataset): task (TaskType): Task type, ``classification``, ``detection`` or ``segmentation`` root (Path | str): Path to the root of the dataset Defaults to ``./datasets/kolektor``. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split (str | Split | None): Split of the dataset, usually Split.TRAIN or Split.TEST Defaults to ``None``. """ @@ -48,10 +45,9 @@ def __init__( self, task: TaskType, root: Path | str = "./datasets/kolektor", - transform: Transform | None = None, split: str | Split | None = None, ) -> None: - super().__init__(task=task, transform=transform) + super().__init__(task) self.root = root self.split = split diff --git a/src/anomalib/data/datasets/image/mvtec.py b/src/anomalib/data/datasets/image/mvtec.py index bb6fdf9e41..2e7e0c2af7 100644 --- a/src/anomalib/data/datasets/image/mvtec.py +++ b/src/anomalib/data/datasets/image/mvtec.py @@ -29,7 +29,6 @@ from pathlib import Path from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base import AnomalibDataset @@ -65,8 +64,6 @@ class MVTecDataset(AnomalibDataset): Defaults to ``./datasets/MVTec``. category (str): Sub-category of the dataset, e.g. 'bottle' Defaults to ``bottle``. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split (str | Split | None): Split of the dataset, usually Split.TRAIN or Split.TEST Defaults to ``None``. @@ -74,12 +71,9 @@ class MVTecDataset(AnomalibDataset): .. code-block:: python from anomalib.data.image.mvtec import MVTecDataset - from anomalib.data.utils.transforms import get_transforms - transform = get_transforms(image_size=256) dataset = MVTecDataset( task="classification", - transform=transform, root='./datasets/MVTec', category='zipper', ) @@ -110,10 +104,9 @@ def __init__( task: TaskType, root: Path | str = "./datasets/MVTec", category: str = "bottle", - transform: Transform | None = None, split: str | Split | None = None, ) -> None: - super().__init__(task=task, transform=transform) + super().__init__(task) self.root_category = Path(root) / Path(category) self.category = category diff --git a/src/anomalib/data/datasets/image/visa.py b/src/anomalib/data/datasets/image/visa.py index 9c5336ab05..f74f2a9535 100644 --- a/src/anomalib/data/datasets/image/visa.py +++ b/src/anomalib/data/datasets/image/visa.py @@ -21,8 +21,6 @@ from pathlib import Path -from torchvision.transforms.v2 import Transform - from anomalib import TaskType from anomalib.data.datasets import AnomalibDataset from anomalib.data.datasets.image.mvtec import make_mvtec_dataset @@ -52,8 +50,6 @@ class VisaDataset(AnomalibDataset): task (TaskType): Task type, ``classification``, ``detection`` or ``segmentation`` root (str | Path): Path to the root of the dataset category (str): Sub-category of the dataset, e.g. 'candle' - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. split (str | Split | None): Split of the dataset, usually Split.TRAIN or Split.TEST Defaults to ``None``. @@ -63,12 +59,9 @@ class VisaDataset(AnomalibDataset): .. code-block:: python from anomalib.data.image.visa import VisaDataset - from anomalib.data.utils.transforms import get_transforms - transform = get_transforms(image_size=256) dataset = VisaDataset( task="classification", - transform=transform, split="train", root="./datasets/visa/visa_pytorch/", category="candle", @@ -86,12 +79,9 @@ class VisaDataset(AnomalibDataset): .. code-block:: python from anomalib.data.image.visa import VisaDataset - from anomalib.data.utils.transforms import get_transforms - transform = get_transforms(image_size=256) dataset = VisaDataset( task="segmentation", - transform=transform, split="train", root="./datasets/visa/visa_pytorch/", category="candle", @@ -109,10 +99,9 @@ def __init__( task: TaskType, root: str | Path, category: str, - transform: Transform | None = None, split: str | Split | None = None, ) -> None: - super().__init__(task=task, transform=transform) + super().__init__(task) self.root_category = Path(root) / category self.split = split diff --git a/src/anomalib/data/datasets/video/avenue.py b/src/anomalib/data/datasets/video/avenue.py index 0d3bd741bf..21c9f49a22 100644 --- a/src/anomalib/data/datasets/video/avenue.py +++ b/src/anomalib/data/datasets/video/avenue.py @@ -20,7 +20,6 @@ import scipy import torch from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.video import AnomalibVideoDataset, VideoTargetFrame @@ -47,18 +46,14 @@ class AvenueDataset(AnomalibVideoDataset): Defaults to ``1``. target_frame (VideoTargetFrame): Specifies the target frame in the video clip, used for ground truth retrieval. Defaults to ``VideoTargetFrame.LAST``. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. Examples: To create an Avenue dataset to train a classification model: .. code-block:: python - transform = A.Compose([A.Resize(256, 256), A.pytorch.ToTensorV2()]) dataset = AvenueDataset( task="classification", - transform=transform, split="train", root="./datasets/avenue/", ) @@ -74,7 +69,6 @@ class AvenueDataset(AnomalibVideoDataset): dataset = AvenueDataset( task="segmentation", - transform=transform, split="test", root="./datasets/avenue/", ) @@ -92,7 +86,6 @@ class AvenueDataset(AnomalibVideoDataset): dataset = AvenueDataset( task="classification", - transform=transform, split="test", root="./datasets/avenue/", clip_length_in_frames=1, @@ -114,7 +107,6 @@ def __init__( gt_dir: Path | str = "./datasets/avenue/ground_truth_demo", clip_length_in_frames: int = 2, frames_between_clips: int = 1, - transform: Transform | None = None, target_frame: VideoTargetFrame = VideoTargetFrame.LAST, ) -> None: super().__init__( @@ -122,7 +114,6 @@ def __init__( clip_length_in_frames=clip_length_in_frames, frames_between_clips=frames_between_clips, target_frame=target_frame, - transform=transform, ) self.root = root if isinstance(root, Path) else Path(root) diff --git a/src/anomalib/data/datasets/video/shanghaitech.py b/src/anomalib/data/datasets/video/shanghaitech.py index e90dbae482..12e8dd985b 100644 --- a/src/anomalib/data/datasets/video/shanghaitech.py +++ b/src/anomalib/data/datasets/video/shanghaitech.py @@ -23,7 +23,6 @@ import pandas as pd import torch from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.video import AnomalibVideoDataset, VideoTargetFrame @@ -42,8 +41,6 @@ class ShanghaiTechDataset(AnomalibVideoDataset): clip_length_in_frames (int, optional): Number of video frames in each clip. frames_between_clips (int, optional): Number of frames between each consecutive video clip. target_frame (VideoTargetFrame): Specifies the target frame in the video clip, used for ground truth retrieval. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. """ def __init__( @@ -55,14 +52,12 @@ def __init__( clip_length_in_frames: int = 2, frames_between_clips: int = 1, target_frame: VideoTargetFrame = VideoTargetFrame.LAST, - transform: Transform | None = None, ) -> None: super().__init__( task=task, clip_length_in_frames=clip_length_in_frames, frames_between_clips=frames_between_clips, target_frame=target_frame, - transform=transform, ) self.root = Path(root) diff --git a/src/anomalib/data/datasets/video/ucsd_ped.py b/src/anomalib/data/datasets/video/ucsd_ped.py index 960218e79e..feeda8ff7f 100644 --- a/src/anomalib/data/datasets/video/ucsd_ped.py +++ b/src/anomalib/data/datasets/video/ucsd_ped.py @@ -9,7 +9,6 @@ import numpy as np import torch from pandas import DataFrame -from torchvision.transforms.v2 import Transform from anomalib import TaskType from anomalib.data.datasets.base.video import AnomalibVideoDataset, VideoTargetFrame @@ -33,8 +32,6 @@ class UCSDpedDataset(AnomalibVideoDataset): clip_length_in_frames (int, optional): Number of video frames in each clip. frames_between_clips (int, optional): Number of frames between each consecutive video clip. target_frame (VideoTargetFrame): Specifies the target frame in the video clip, used for ground truth retrieval. - transform (Transform, optional): Transforms that should be applied to the input images. - Defaults to ``None``. """ def __init__( @@ -46,14 +43,12 @@ def __init__( clip_length_in_frames: int = 2, frames_between_clips: int = 10, target_frame: VideoTargetFrame = VideoTargetFrame.LAST, - transform: Transform | None = None, ) -> None: super().__init__( task=task, clip_length_in_frames=clip_length_in_frames, frames_between_clips=frames_between_clips, target_frame=target_frame, - transform=transform, ) self.root_category = Path(root) / category diff --git a/src/anomalib/data/utils/synthetic.py b/src/anomalib/data/utils/synthetic.py index 16aa20d83d..c9626f81c1 100644 --- a/src/anomalib/data/utils/synthetic.py +++ b/src/anomalib/data/utils/synthetic.py @@ -16,7 +16,6 @@ import cv2 import pandas as pd from pandas import DataFrame, Series -from torchvision.transforms.v2 import Compose from anomalib import TaskType from anomalib.data.datasets.base.image import AnomalibDataset @@ -80,7 +79,7 @@ def augment(sample: Series) -> Series: Returns: Series: DataFrame row with updated information about the augmented image. """ - # read and transform image + # read image image = read_image(sample.image_path, as_tensor=True) # apply anomalous perturbation aug_im, mask = augmenter.augment_batch(image.unsqueeze(0)) @@ -114,12 +113,11 @@ class SyntheticAnomalyDataset(AnomalibDataset): Args: task (str): Task type, either "classification" or "segmentation". - transform (A.Compose): Transform object describing the transforms that are applied to the inputs. source_samples (DataFrame): Normal samples to which the anomalous augmentations will be applied. """ - def __init__(self, task: TaskType, transform: Compose, source_samples: DataFrame) -> None: - super().__init__(task, transform) + def __init__(self, task: TaskType, source_samples: DataFrame) -> None: + super().__init__(task) self.source_samples = source_samples @@ -146,7 +144,7 @@ def from_dataset(cls: type["SyntheticAnomalyDataset"], dataset: AnomalibDataset) dataset (AnomalibDataset): Dataset consisting of only normal images that will be converrted to a synthetic anomalous dataset with a 50/50 normal anomalous split. """ - return cls(task=dataset.task, transform=dataset.transform, source_samples=dataset.samples) + return cls(task=dataset.task, source_samples=dataset.samples) def __copy__(self) -> "SyntheticAnomalyDataset": """Return a shallow copy of the dataset object and prevents cleanup when original object is deleted."""