Skip to content

Commit

Permalink
Enable training with only normal images for MVTec (openvinotoolkit#1241)
Browse files Browse the repository at this point in the history
* ignore mask check when dataset has only normal samples

* update changelog
  • Loading branch information
djdameln authored Aug 7, 2023
1 parent 5a46d03 commit 3ffc3f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed

- Enable training with only normal images for MVTecv in https://github.com/openvinotoolkit/anomalib/pull/1241
- Improve default settings of EfficientAD

### Deprecated
Expand Down
15 changes: 8 additions & 7 deletions src/anomalib/data/mvtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ def make_mvtec_dataset(
] = mask_samples.image_path.values

# assert that the right mask files are associated with the right test images
assert (
samples.loc[samples.label_index == LabelName.ABNORMAL]
.apply(lambda x: Path(x.image_path).stem in Path(x.mask_path).stem, axis=1)
.all()
), "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')."
if len(samples.loc[samples.label_index == LabelName.ABNORMAL]):
assert (
samples.loc[samples.label_index == LabelName.ABNORMAL]
.apply(lambda x: Path(x.image_path).stem in Path(x.mask_path).stem, axis=1)
.all()
), "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')."

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

0 comments on commit 3ffc3f6

Please sign in to comment.