Files
zeekay dda5b2a367 restore the tree
The previous commit was meant to remove .github/workflows and removed
every tracked path instead — 892 files, the whole repo. This puts back
the 874 that were never in scope; the eighteen workflow files stay gone,
for the reasons that commit gives.

Content is byte-identical to 9d2aec9 outside .github/workflows.
2026-08-13 23:27:57 -07:00

46 lines
1.4 KiB
Python

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
"""Example showing how to use your own dataset with Anomalib.
This example demonstrates how to use a custom folder dataset where images
are organized in a specific directory structure.
"""
from pathlib import Path
from anomalib.data import Folder
# 1. Basic Usage with Default Structure
# Default structure expects:
# - train/good: Normal (good) training images
# - test/good: Normal test images
# - test/defect: Anomalous test images
datamodule = Folder(
name="my_dataset",
root=Path("./datasets/my_dataset"),
normal_dir="good", # Subfolder containing normal images
abnormal_dir="defect", # Subfolder containing anomalous images
)
# 2. Custom Directory Structure
# For a different directory structure:
# my_dataset/
# ├── train/
# │ └── normal/ # Normal training images
# ├── val/
# │ ├── normal/ # Normal validation images
# │ └── anomaly/ # Anomalous validation images
# └── test/
# ├── normal/ # Normal test images
# └── anomaly/ # Anomalous test images
datamodule = Folder(
name="my_dataset",
root=Path("./datasets/my_dataset"),
normal_dir="normal", # Subfolder containing normal images
abnormal_dir="anomaly", # Subfolder containing anomalous images
train_batch_size=32,
eval_batch_size=32,
num_workers=8,
)