Skip to content

Commit

Permalink
Rename MisMatch to Mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
samet-akcay committed Jul 1, 2024
1 parent 63fd070 commit 7c68b10
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/anomalib/data/depth/folder_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


from pathlib import Path

from pandas import DataFrame, isna
from torchvision.transforms.v2 import Transform

from anomalib import TaskType
from anomalib.data.base import AnomalibDataModule, AnomalibDepthDataset
from anomalib.data.errors import MisMatchError
from anomalib.data.errors import MismatchError
from anomalib.data.utils import (
DirType,
LabelName,
Expand Down Expand Up @@ -141,7 +140,7 @@ def make_folder3d_dataset( # noqa: C901
msg = """Mismatch between anomalous images and depth images. Make sure the mask files
in 'xyz' folder follow the same naming convention as the anomalous images in the dataset
(e.g. image: '000.png', depth: '000.tiff')."""
raise MisMatchError(msg)
raise MismatchError(msg)

missing_depth_files = samples.depth_path.apply(
lambda x: Path(x).exists() if not isna(x) else True,
Expand Down
7 changes: 3 additions & 4 deletions src/anomalib/data/depth/mvtec_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


import logging
from collections.abc import Sequence
from pathlib import Path
Expand All @@ -29,7 +28,7 @@

from anomalib import TaskType
from anomalib.data.base import AnomalibDataModule, AnomalibDepthDataset
from anomalib.data.errors import MisMatchError
from anomalib.data.errors import MismatchError
from anomalib.data.utils import (
DownloadInfo,
LabelName,
Expand Down Expand Up @@ -156,7 +155,7 @@ def make_mvtec_3d_dataset(
msg = """Mismatch between anomalous images and ground truth masks. Make sure the mask files
in 'ground_truth' folder follow the same naming convention as the anomalous images in
the dataset (e.g. image: '000.png', mask: '000.png' or '000_mask.png')."""
raise MisMatchError(msg)
raise MismatchError(msg)

mismatch_depth = (
samples.loc[samples.label_index == LabelName.ABNORMAL]
Expand All @@ -167,7 +166,7 @@ def make_mvtec_3d_dataset(
msg = """Mismatch between anomalous images and depth images. Make sure the mask files in
'xyz' folder follow the same naming convention as the anomalous images in the dataset
(e.g. image: '000.png', depth: '000.tiff')."""
raise MisMatchError(msg)
raise MismatchError(msg)

if split:
samples = samples[samples.split == split].reset_index(drop=True)
Expand Down
8 changes: 7 additions & 1 deletion src/anomalib/data/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from anomalib.utils import create_class_alias_with_deprecation_warning

class MisMatchError(Exception):

class MismatchError(Exception):
"""Exception raised when a mismatch is detected.
Attributes:
Expand All @@ -17,3 +19,7 @@ def __init__(self, message: str = "") -> None:
else:
self.message = "Mismatch detected."
super().__init__(self.message)


# NOTE: This is deprecated and will be removed in a future release.
MisMatchError = create_class_alias_with_deprecation_warning(MismatchError, "MisMatchError")
4 changes: 2 additions & 2 deletions src/anomalib/data/image/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from anomalib import TaskType
from anomalib.data.base import AnomalibDataModule, AnomalibDataset
from anomalib.data.errors import MisMatchError
from anomalib.data.errors import MismatchError
from anomalib.data.utils import (
DirType,
LabelName,
Expand Down Expand Up @@ -154,7 +154,7 @@ def _resolve_path_and_convert_to_list(path: str | Path | Sequence[str | Path] |
msg = """Mismatch between anomalous images and mask images. Make sure the mask files "
"folder follow the same naming convention as the anomalous images in the dataset "
"(e.g. image: '000.png', mask: '000.png')."""
raise MisMatchError(msg)
raise MismatchError(msg)

else:
samples["mask_path"] = ""
Expand Down
4 changes: 2 additions & 2 deletions src/anomalib/data/image/kolektor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from anomalib import TaskType
from anomalib.data.base import AnomalibDataModule, AnomalibDataset
from anomalib.data.errors import MisMatchError
from anomalib.data.errors import MismatchError
from anomalib.data.utils import (
DownloadInfo,
Split,
Expand Down Expand Up @@ -174,7 +174,7 @@ def make_kolektor_dataset(
msg = """Mismatch between anomalous images and ground truth masks. Make sure the mask files
follow the same naming convention as the anomalous images in the dataset
(e.g. image: 'Part0.jpg', mask: 'Part0_label.bmp')."""
raise MisMatchError(msg)
raise MismatchError(msg)

# Get the dataframe for the required split
if split:
Expand Down
4 changes: 2 additions & 2 deletions src/anomalib/data/image/mvtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from anomalib import TaskType
from anomalib.data.base import AnomalibDataModule, AnomalibDataset
from anomalib.data.errors import MisMatchError
from anomalib.data.errors import MismatchError
from anomalib.data.utils import (
DownloadInfo,
LabelName,
Expand Down Expand Up @@ -162,7 +162,7 @@ def make_mvtec_dataset(
msg = """Mismatch between anomalous images and ground truth masks. Make sure t
he mask files in 'ground_truth' folder follow the same naming convention as the
anomalous images in the dataset (e.g. image: '000.png', mask: '000.png' or '000_mask.png')."""
raise MisMatchError(msg)
raise MismatchError(msg)

if split:
samples = samples[samples.split == split].reset_index(drop=True)
Expand Down

0 comments on commit 7c68b10

Please sign in to comment.