From b2598583fa50628882ecdf79ba6cc9df07ade91f Mon Sep 17 00:00:00 2001 From: Ashwin Vaidya Date: Fri, 12 Apr 2024 08:25:08 +0200 Subject: [PATCH] Remove Draem Signed-off-by: Ashwin Vaidya --- src/otx/algo/anomaly/__init__.py | 3 +- src/otx/algo/anomaly/draem.py | 42 ---------- .../recipe/anomaly_classification/draem.yaml | 78 ------------------- src/otx/recipe/anomaly_detection/draem.yaml | 78 ------------------- .../recipe/anomaly_segmentation/draem.yaml | 78 ------------------- 5 files changed, 1 insertion(+), 278 deletions(-) delete mode 100644 src/otx/algo/anomaly/draem.py delete mode 100644 src/otx/recipe/anomaly_classification/draem.yaml delete mode 100644 src/otx/recipe/anomaly_detection/draem.yaml delete mode 100644 src/otx/recipe/anomaly_segmentation/draem.yaml diff --git a/src/otx/algo/anomaly/__init__.py b/src/otx/algo/anomaly/__init__.py index 34c9bded182..6182b285077 100644 --- a/src/otx/algo/anomaly/__init__.py +++ b/src/otx/algo/anomaly/__init__.py @@ -3,8 +3,7 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 -from .draem import Draem from .padim import Padim from .stfpm import Stfpm -__all__ = ["Draem", "Padim", "Stfpm"] +__all__ = ["Padim", "Stfpm"] diff --git a/src/otx/algo/anomaly/draem.py b/src/otx/algo/anomaly/draem.py deleted file mode 100644 index 39ba92c8faa..00000000000 --- a/src/otx/algo/anomaly/draem.py +++ /dev/null @@ -1,42 +0,0 @@ -"""OTX Draem model.""" - -# Copyright (C) 2024 Intel Corporation -# SPDX-License-Identifier: Apache-2.0 - -from __future__ import annotations - -from anomalib.models.image import Draem as AnomalibDraem - -from otx.core.model.entity.base import OTXModel -from otx.core.model.module.anomaly import OTXAnomaly - - -class Draem(OTXAnomaly, OTXModel, AnomalibDraem): - """OTX Draem model. - - Args: - enable_sspcab (bool): Enable SSPCAB training. Defaults to ``False``. - sspcab_lambda (float): SSPCAB loss weight. Defaults to ``0.1``. - anomaly_source_path (str | None): Path to folder that contains the anomaly source images. Random noise will - be used if left empty. Defaults to ``None``. - beta (float | tuple[float, float]): Parameter that determines the opacity of the noise mask. - Defaults to ``(0.1, 1.0)``. - """ - - def __init__( - self, - enable_sspcab: bool = False, - sspcab_lambda: float = 0.1, - anomaly_source_path: str | None = None, - beta: float | tuple[float, float] = (0.1, 1.0), - num_classes: int = 2, - ) -> None: - OTXAnomaly.__init__(self) - OTXModel.__init__(self, num_classes=num_classes) - AnomalibDraem.__init__( - self, - enable_sspcab=enable_sspcab, - sspcab_lambda=sspcab_lambda, - anomaly_source_path=anomaly_source_path, - beta=beta, - ) diff --git a/src/otx/recipe/anomaly_classification/draem.yaml b/src/otx/recipe/anomaly_classification/draem.yaml deleted file mode 100644 index 113ddc846fe..00000000000 --- a/src/otx/recipe/anomaly_classification/draem.yaml +++ /dev/null @@ -1,78 +0,0 @@ -model: - class_path: otx.algo.anomaly.draem.Draem - init_args: - enable_sspcab: false - sspcab_lambda: 0.1 - anomaly_source_path: null - beta: [0.1, 1.0] - -engine: - task: ANOMALY_CLASSIFICATION - device: auto - -callback_monitor: image_AUROC - -data: ../_base_/data/torchvision_base.yaml -overrides: - max_epochs: 700 - num_sanity_val_steps: 0 - callbacks: - - class_path: lightning.pytorch.callbacks.EarlyStopping - init_args: - patience: 5 - mode: max - - class_path: otx.algo.callbacks.adaptive_train_scheduling.AdaptiveTrainScheduling - init_args: - max_interval: 1 - data: - task: ANOMALY_CLASSIFICATION - config: - data_format: mvtec - train_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - val_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - test_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] diff --git a/src/otx/recipe/anomaly_detection/draem.yaml b/src/otx/recipe/anomaly_detection/draem.yaml deleted file mode 100644 index ef0b7873075..00000000000 --- a/src/otx/recipe/anomaly_detection/draem.yaml +++ /dev/null @@ -1,78 +0,0 @@ -model: - class_path: otx.algo.anomaly.draem.Draem - init_args: - enable_sspcab: false - sspcab_lambda: 0.1 - anomaly_source_path: null - beta: [0.1, 1.0] - -engine: - task: ANOMALY_DETECTION - device: auto - -callback_monitor: pixel_AUROC - -data: ../_base_/data/torchvision_base.yaml -overrides: - max_epochs: 700 - num_sanity_val_steps: 0 - callbacks: - - class_path: lightning.pytorch.callbacks.EarlyStopping - init_args: - patience: 5 - mode: max - - class_path: otx.algo.callbacks.adaptive_train_scheduling.AdaptiveTrainScheduling - init_args: - max_interval: 1 - data: - task: ANOMALY_DETECTION - config: - data_format: mvtec - train_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - val_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - test_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] diff --git a/src/otx/recipe/anomaly_segmentation/draem.yaml b/src/otx/recipe/anomaly_segmentation/draem.yaml deleted file mode 100644 index f36887b92e1..00000000000 --- a/src/otx/recipe/anomaly_segmentation/draem.yaml +++ /dev/null @@ -1,78 +0,0 @@ -model: - class_path: otx.algo.anomaly.draem.Draem - init_args: - enable_sspcab: false - sspcab_lambda: 0.1 - anomaly_source_path: null - beta: [0.1, 1.0] - -engine: - task: ANOMALY_SEGMENTATION - device: auto - -callback_monitor: pixel_AUROC - -data: ../_base_/data/torchvision_base.yaml -overrides: - max_epochs: 700 - num_sanity_val_steps: 0 - callbacks: - - class_path: lightning.pytorch.callbacks.EarlyStopping - init_args: - patience: 5 - mode: max - - class_path: otx.algo.callbacks.adaptive_train_scheduling.AdaptiveTrainScheduling - init_args: - max_interval: 1 - data: - task: ANOMALY_SEGMENTATION - config: - data_format: mvtec - train_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - val_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375] - test_subset: - batch_size: 8 - num_workers: 4 - transforms: - - class_path: torchvision.transforms.v2.Resize - init_args: - size: [256, 256] - antialias: True - - class_path: torchvision.transforms.v2.ToDtype - init_args: - dtype: ${as_torch_dtype:torch.float32} - scale: False - - class_path: torchvision.transforms.v2.Normalize - init_args: - mean: [123.675, 116.28, 103.53] - std: [58.395, 57.12, 57.375]