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

Enable training with only normal images for MVTec #1241

Merged
merged 2 commits into from
Aug 7, 2023
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
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