Skip to content

Commit

Permalink
validate path before processing
Browse files Browse the repository at this point in the history
Signed-off-by: Willy Fitra Hendria <[email protected]>
  • Loading branch information
willyfh committed Feb 1, 2024
1 parent f7fc290 commit a119c36
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/anomalib/data/image/mvtec_loco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
get_transforms,
masks_to_boxes,
read_image,
validate_path,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -96,9 +97,9 @@ def load_saturation_config(config_path: str | Path) -> dict[int, Any] | None:
]
"""
try:
with Path.open(Path(config_path)) as file:
config_path = validate_path(config_path)
with Path.open(config_path) as file:
configs = json.load(file)

# Create a dictionary with pixel values as keys
return {conf["pixel_value"]: conf for conf in configs}
except FileNotFoundError:
Expand Down Expand Up @@ -205,7 +206,7 @@ def make_mvtec_loco_dataset(
>>> path = root / category
>>> samples = make_mvtec_loco_dataset(path, split='test')
"""
root = Path(root)
root = validate_path(root)
gt_merged_dir = Path(gt_merged_dir)

# assert the directory to store the merged ground-truth masks is different than the original gt directory
Expand Down

0 comments on commit a119c36

Please sign in to comment.