Skip to content

Commit

Permalink
Merge pull request #3777 from harimkang/harimkan/refactor-recipe-anomaly
Browse files Browse the repository at this point in the history
Refine recipes for anomaly tasks
  • Loading branch information
harimkang authored Jul 31, 2024
2 parents 6c3554e + 59e8360 commit b33e964
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 382 deletions.
76 changes: 76 additions & 0 deletions src/otx/recipe/_base_/data/anomaly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
task: ANOMALY_CLASSIFICATION
input_size: 256
data_format: mvtec
mem_cache_size: 1GB
mem_cache_img_max_size: null
image_color_channel: RGB
stack_images: false
unannotated_items_ratio: 0.0
train_subset:
subset_name: train
transform_lib_type: TORCHVISION
to_tv_image: true
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
sampler:
class_path: torch.utils.data.RandomSampler

val_subset:
subset_name: test
transform_lib_type: TORCHVISION
to_tv_image: true
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
sampler:
class_path: torch.utils.data.RandomSampler

test_subset:
subset_name: test
transform_lib_type: TORCHVISION
to_tv_image: true
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
sampler:
class_path: torch.utils.data.RandomSampler
69 changes: 1 addition & 68 deletions src/otx/recipe/anomaly_classification/padim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,11 @@ engine:

callback_monitor: image_F1Score # this has no effect as Padim does not need to be trained

data: ../_base_/data/torchvision_base.yaml
data: ../_base_/data/anomaly.yaml
overrides:
reset:
- data.train_subset.transforms
- data.val_subset.transforms
- data.test_subset.transforms

precision: 32
max_epochs: 1
callbacks:
- class_path: otx.algo.callbacks.adaptive_train_scheduling.AdaptiveTrainScheduling
init_args:
max_interval: 1

data:
task: ANOMALY_CLASSIFICATION
input_size: 256
data_format: mvtec
vpm_config:
use_bbox: true
use_point: false
train_subset:
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
subset_name: test
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
66 changes: 1 addition & 65 deletions src/otx/recipe/anomaly_classification/stfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ engine:

callback_monitor: image_F1Score

data: ../_base_/data/torchvision_base.yaml
data: ../_base_/data/anomaly.yaml
overrides:
reset:
- data.train_subset.transforms
- data.val_subset.transforms
- data.test_subset.transforms

precision: 32
max_epochs: 100
callbacks:
Expand All @@ -27,62 +22,3 @@ overrides:
- class_path: otx.algo.callbacks.adaptive_train_scheduling.AdaptiveTrainScheduling
init_args:
max_interval: 1

data:
task: ANOMALY_CLASSIFICATION
input_size: 256
data_format: mvtec
train_subset:
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
subset_name: test
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
66 changes: 1 addition & 65 deletions src/otx/recipe/anomaly_detection/padim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ engine:

callback_monitor: image_F1Score # this has no effect as Padim does not need to be trained

data: ../_base_/data/torchvision_base.yaml
data: ../_base_/data/anomaly.yaml
overrides:
reset:
- data.train_subset.transforms
- data.val_subset.transforms
- data.test_subset.transforms

precision: 32
max_epochs: 1
callbacks:
Expand All @@ -29,62 +24,3 @@ overrides:

data:
task: ANOMALY_DETECTION
input_size: 256
data_format: mvtec
vpm_config:
use_bbox: true
use_point: false
train_subset:
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
subset_name: test
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
58 changes: 1 addition & 57 deletions src/otx/recipe/anomaly_detection/stfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ engine:

callback_monitor: pixel_F1Score

data: ../_base_/data/torchvision_base.yaml
data: ../_base_/data/anomaly.yaml
overrides:
reset:
- data.train_subset.transforms
Expand All @@ -30,59 +30,3 @@ overrides:

data:
task: ANOMALY_DETECTION
input_size: 256
data_format: mvtec
train_subset:
batch_size: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
subset_name: test
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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: 32
num_workers: 4
transforms:
- class_path: otx.core.data.transform_libs.torchvision.ResizetoLongestEdge
init_args:
size: $(input_size)
antialias: true
- class_path: otx.core.data.transform_libs.torchvision.PadtoSquare
- 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]
Loading

0 comments on commit b33e964

Please sign in to comment.