Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sstrehlk/Changed directories structure for anomaly templates. #1105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you want to add training code of your model to this repository, make sure:
1. [IInferenceTask](https://github.com/openvinotoolkit/training_extensions/blob/develop/ote_sdk/ote_sdk/usecases/tasks/interfaces/inference_interface.py) - your model must be inferable on some datasets.
1. [IEvaluationTask](https://github.com/openvinotoolkit/training_extensions/blob/develop/ote_sdk/ote_sdk/usecases/tasks/interfaces/evaluate_interface.py) - it must be possible to evaluate some quality metric of you model.
1. [IExportTask](https://github.com/openvinotoolkit/training_extensions/blob/develop/ote_sdk/ote_sdk/usecases/tasks/interfaces/export_interface.py) - your model must be exportable to the OpenVINO format.
4. You provide a model `template.yaml` file, that describes your model and its configurable parameters. See an example [here](external/anomaly/anomaly_classification/configs/padim/template.yaml).
4. You provide a model `template.yaml` file, that describes your model and its configurable parameters. See an example [here](external/anomaly/configs/anomaly_classification/padim/template.yaml).
5. You create a PR to the `develop` branch.
6. You provide `requirements.txt` file and a bash `init_venv.sh` script for creating virtual environment.

Expand Down
12 changes: 6 additions & 6 deletions external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ Every sub-project is fully indepedent from each other, and each of them has its
## Anomaly Classification
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
ote_anomaly_classification_padim | PADIM | 3.9 | 168.4 | anomaly/anomaly_classification/configs/padim/template.yaml
ote_anomaly_classification_stfpm | STFPM | 5.6 | 21.1 | anomaly/anomaly_classification/configs/stfpm/template.yaml
ote_anomaly_classification_padim | PADIM | 3.9 | 168.4 | anomaly/configs/anomaly_classification/padim/template.yaml
ote_anomaly_classification_stfpm | STFPM | 5.6 | 21.1 | anomaly/configs/anomaly_classification/stfpm/template.yaml

## Anomaly Detection
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
ote_anomaly_detection_padim | PADIM | 3.9 | 168.4 | anomaly/anomaly_detection/configs/padim/template.yaml
ote_anomaly_detection_stfpm | STFPM | 5.6 | 21.1 | anomaly/anomaly_detection/configs/stfpm/template.yaml
ote_anomaly_detection_padim | PADIM | 3.9 | 168.4 | anomaly/configs/anomaly_detection/padim/template.yaml
ote_anomaly_detection_stfpm | STFPM | 5.6 | 21.1 | anomaly/configs/anomaly_detection/stfpm/template.yaml

## Anomaly Segmentation
ID | Name | Complexity (GFlops) | Model size (MB) | Path
------- | ------- | ------- | ------- | -------
ote_anomaly_segmentation_padim | PADIM | 3.9 | 168.4 | anomaly/anomaly_segmentation/configs/padim/template.yaml
ote_anomaly_segmentation_stfpm | STFPM | 5.6 | 21.1 | anomaly/anomaly_segmentation/configs/stfpm/template.yaml
ote_anomaly_segmentation_padim | PADIM | 3.9 | 168.4 | anomaly/configs/anomaly_segmentation/padim/template.yaml
ote_anomaly_segmentation_stfpm | STFPM | 5.6 | 21.1 | anomaly/configs/anomaly_segmentation/stfpm/template.yaml

## Image Classification
ID | Name | Complexity (GFlops) | Model size (MB) | Path
Expand Down
17 changes: 0 additions & 17 deletions external/anomaly/anomaly_classification/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions external/anomaly/anomaly_detection/__init__.py

This file was deleted.

17 changes: 0 additions & 17 deletions external/anomaly/anomaly_segmentation/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion external/anomaly/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def ote_templates_root_dir_fx():

logger = logging.getLogger(__name__)
root = osp.dirname(osp.dirname(osp.realpath(__file__)))
root = f"{root}/anomaly_classification/"
root = f"{root}/configs/"
logger.debug(f"overloaded ote_templates_root_dir_fx: return {root}")
return root

Expand Down
6 changes: 3 additions & 3 deletions external/anomaly/tests/test_configurable_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import os

import pytest
from anomaly_classification.configs.padim import PadimAnomalyClassificationConfig
from anomaly_classification.configs.stfpm import STFPMAnomalyClassificationConfig
from configs.anomaly_classification.padim import PadimAnomalyClassificationConfig
from configs.anomaly_classification.stfpm import STFPMAnomalyClassificationConfig
from ote_anomalib.configs import get_anomalib_config
from ote_sdk.configuration.helper import convert, create
from tests.helpers.config import get_config_and_task_name
Expand All @@ -35,7 +35,7 @@
)
def test_configuration_yaml(configurable_parameters, model_name):
# assert that we can parse the template.yaml
template_file_path = os.path.join("anomaly_classification", "configs", model_name, "template.yaml")
template_file_path = os.path.join("configs", "anomaly_classification", model_name, "template.yaml")
configuration_yaml_loaded, task_name = get_config_and_task_name(template_file_path)

configuration = configurable_parameters()
Expand Down
2 changes: 1 addition & 1 deletion external/anomaly/tests/test_ote_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _run_ote_training(self, data_collector):

logger.debug("Set hyperparameters")
params = ote_sdk_configuration_helper_create(self.model_template.hyper_parameters.data)
if hasattr(params, "model"):
if hasattr(params, "model") and hasattr(params.model, "early_stopping"):
if self.num_training_iters != KEEP_CONFIG_FIELD_VALUE:
params.model.early_stopping.patience = int(self.num_training_iters)
logger.debug(f"Set params.model.early_stopping.patience=" f"{params.model.early_stopping.patience}")
Expand Down
4 changes: 2 additions & 2 deletions external/anomaly/tools/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(

If MVTec dataset is placed under the above directory, then we could run,

>>> model_template_path = "./anomaly_classification/configs/padim/template.yaml"
>>> model_template_path = "./configs/anomaly_classification/padim/template.yaml"
>>> dataset_path = "./datasets/MVTec"
>>> seed = 0
>>> task = OteAnomalyTask(
Expand Down Expand Up @@ -337,7 +337,7 @@ def parse_args() -> Namespace:
)
parser.add_argument(
"--model_template_path",
default="./anomaly_classification/configs/padim/template.yaml",
default="./configs/anomaly_classification/padim/template.yaml",
)
parser.add_argument("--dataset_path", default="./datasets/MVTec")
parser.add_argument("--category", default="bottle")
Expand Down