Skip to content

Commit

Permalink
[Anomaly Task] Revert hpo template (#1230)
Browse files Browse the repository at this point in the history
* Move configuration.yaml and associated files to tempates folder.

* Revert to old configuration format + fix save model issue

* Update nncf compression_config.json path

* Disable editable in pruning_supported

* Remove copy

* Move algorithm/configuration.py to base
  • Loading branch information
ashwinvaidya17 authored Sep 1, 2022
1 parent 86e9e4a commit daf75ac
Show file tree
Hide file tree
Showing 67 changed files with 2,275 additions and 39 deletions.
6 changes: 4 additions & 2 deletions external/anomaly/configs/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# See the License for the specific language governing permissions
# and limitations under the License.

from .configuration import BaseAnomalyConfig
from .draem import DraemAnomalyBaseConfig
from .padim import PadimAnomalyBaseConfig
from .stfpm import STFPMAnomalyBaseConfig

__all__ = ["BaseAnomalyConfig"]
__all__ = ["PadimAnomalyBaseConfig", "STFPMAnomalyBaseConfig", "DraemAnomalyBaseConfig"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Base configuration parameters for Draem
"""
"""Base configuration parameters for Draem."""

# Copyright (C) 2021-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""
Configurable parameters for Draem anomaly task
"""
"""Configurable parameters for Draem anomaly task."""

# Copyright (C) 2021-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


from attr import attrs
from configs.base import BaseAnomalyConfig
from configs.base.configuration import BaseAnomalyConfig
from configs.base.configuration_enums import EarlyStoppingMetrics
from ote_sdk.configuration.elements import (
ParameterGroup,
Expand All @@ -22,9 +20,7 @@

@attrs
class DraemAnomalyBaseConfig(BaseAnomalyConfig):
"""
Configurable parameters for DRAEM anomaly classification task.
"""
"""Configurable parameters for DRAEM anomaly classification task."""

header = string_attribute("Configuration for Draem")
description = header
Expand Down Expand Up @@ -59,9 +55,7 @@ class LearningParameters(BaseAnomalyConfig.LearningParameters):

@attrs
class EarlyStoppingParameters(ParameterGroup):
"""
Early stopping parameters
"""
"""Early stopping parameters."""

header = string_attribute("Early Stopping Parameters")
description = header
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# and limitations under the License.

from attr import attrs
from configs.base import BaseAnomalyConfig
from configs.base.configuration import BaseAnomalyConfig
from configs.base.configuration_enums import ModelBackbone
from ote_sdk.configuration.elements import (
add_parameter_group,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# and limitations under the License.

from attr import attrs
from configs.base import BaseAnomalyConfig
from configs.base.configuration import BaseAnomalyConfig
from configs.base.configuration_enums import EarlyStoppingMetrics, ModelBackbone
from ote_sdk.configuration.elements import (
ParameterGroup,
Expand Down
15 changes: 15 additions & 0 deletions external/anomaly/configs/classification/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Configuration for classification tasks."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
19 changes: 19 additions & 0 deletions external/anomaly/configs/classification/draem/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Initialization of Configurable Parameters for DRAEM Anomaly Classification Task."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from .configuration import DraemAnomalyClassificationConfig

__all__ = ["DraemAnomalyClassificationConfig"]
23 changes: 23 additions & 0 deletions external/anomaly/configs/classification/draem/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Configurable parameters for DRAEM anomaly classification task."""

# Copyright (C) 2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from attr import attrs
from configs.base import DraemAnomalyBaseConfig


@attrs
class DraemAnomalyClassificationConfig(DraemAnomalyBaseConfig):
"""Configurable parameters for DRAEM anomaly classification task."""
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ nncf_optimization:
auto_hpo_value: null
default_value: false
description: Whether filter pruning is supported
editable: true
editable: false
header: Whether filter pruning is supported
type: BOOLEAN
ui_rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ entrypoints:

# Hyper Parameters
hyper_parameters:
base_path: ../../../configs/draem/configuration.yaml
base_path: ./configuration.yaml

# Training resources.
max_nodes: 1
Expand Down
19 changes: 19 additions & 0 deletions external/anomaly/configs/classification/padim/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Initialization of Configurable Parameters for PADIM Anomaly Classification Task."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from .configuration import PadimAnomalyClassificationConfig

__all__ = ["PadimAnomalyClassificationConfig"]
23 changes: 23 additions & 0 deletions external/anomaly/configs/classification/padim/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Configurable parameters for Padim anomaly classification task."""

# Copyright (C) 2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from attr import attrs
from configs.base import PadimAnomalyBaseConfig


@attrs
class PadimAnomalyClassificationConfig(PadimAnomalyBaseConfig):
"""Configurable parameters for PADIM anomaly classification task."""
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ nncf_optimization:
auto_hpo_value: null
default_value: false
description: Whether filter pruning is supported
editable: true
editable: false
header: Whether filter pruning is supported
type: BOOLEAN
ui_rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ entrypoints:

# Hyper Parameters
hyper_parameters:
base_path: ../../../configs/padim/configuration.yaml
base_path: ./configuration.yaml

# Training resources.
max_nodes: 1
Expand Down
19 changes: 19 additions & 0 deletions external/anomaly/configs/classification/stfpm/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Initialization of Configurable Parameters for STFPM Anomaly Classification Task."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from .configuration import STFPMAnomalyClassificationConfig

__all__ = ["STFPMAnomalyClassificationConfig"]
23 changes: 23 additions & 0 deletions external/anomaly/configs/classification/stfpm/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Configurable parameters for STFPM anomaly classification task."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from attr import attrs
from configs.base import STFPMAnomalyBaseConfig


@attrs
class STFPMAnomalyClassificationConfig(STFPMAnomalyBaseConfig):
"""Configurable parameters for STFPM anomaly classification task."""
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ nncf_optimization:
auto_hpo_value: null
default_value: false
description: Whether filter pruning is supported
editable: true
editable: false
header: Whether filter pruning is supported
type: BOOLEAN
ui_rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ entrypoints:

# Hyper Parameters
hyper_parameters:
base_path: ../../../configs/stfpm/configuration.yaml
base_path: ./configuration.yaml
parameter_overrides:
learning_parameters:
train_batch_size:
Expand Down
15 changes: 15 additions & 0 deletions external/anomaly/configs/detection/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Configuration for detection tasks."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.
19 changes: 19 additions & 0 deletions external/anomaly/configs/detection/draem/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Initialization of Configurable Parameters for DRAEM Anomaly Detection Task."""

# Copyright (C) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from .configuration import DraemAnomalyDetectionConfig

__all__ = ["DraemAnomalyDetectionConfig"]
36 changes: 36 additions & 0 deletions external/anomaly/configs/detection/draem/compression_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"base": {
"find_unused_parameters": true,
"target_metric_name": "image_F1Score",
"nncf_config": {
"input_info": {
"sample_size": [1, 3, 256, 256]
},
"compression": [],
"log_dir": "/tmp"
}
},
"nncf_quantization": {
"model": {
"lr": 0.004
},
"nncf_config": {
"compression": [
{
"algorithm": "quantization",
"preset": "mixed",
"initializer": {
"range": {
"num_init_samples": 250
},
"batchnorm_adaptation": {
"num_bn_adaptation_samples": 250
}
},
"ignored_scopes": []
}
]
}
},
"order_of_parts": ["nncf_quantization"]
}
23 changes: 23 additions & 0 deletions external/anomaly/configs/detection/draem/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Configurable parameters for DRAEM anomaly Detection task."""

# Copyright (C) 2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions
# and limitations under the License.

from attr import attrs
from configs.base import DraemAnomalyBaseConfig


@attrs
class DraemAnomalyDetectionConfig(DraemAnomalyBaseConfig):
"""Configurable parameters for DRAEM anomaly Detection task."""
Loading

0 comments on commit daf75ac

Please sign in to comment.