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

v1 - [Refactor] Reflect the changes in #1562 into v1 #1595

Merged
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
6 changes: 5 additions & 1 deletion src/anomalib/data/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ def _prepare_files_labels(
if isinstance(extensions, str):
extensions = (extensions,)

if not all(extension.startswith(".") for extension in extensions):
msg = f"All extensions {extensions} must start with the dot"
raise RuntimeError(msg)

filenames = [
f
for f in path.glob("**/*")
if f.suffix in extensions and not f.is_dir() and not any(part.startswith(".") for part in f.parts)
]
if not filenames:
msg = f"Found 0 {path_type} images in {path}"
msg = f"Found 0 {path_type} images in {path} with extensions {extensions}"
raise RuntimeError(msg)

labels = [path_type] * len(filenames)
Expand Down
Loading