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

Add MVTec LOCO dataset #2607

Merged
merged 12 commits into from
Mar 21, 2025

Conversation

samet-akcay
Copy link
Contributor

Add MVTec LOCO Dataset Support

Description

This PR adds support for the MVTec LOCO dataset in the Anomalib framework. The implementation includes dataset and datamodule classes, along with example configurations and tests.

Changes

  • Added new dataset implementation: src/anomalib/data/datasets/image/mvtec_loco.py
  • Added new datamodule implementation: src/anomalib/data/datamodules/image/mvtec_loco.py
  • Added example configuration: examples/configs/data/mvtec_loco.yaml
  • Added example usage script: examples/api/02_data/mvtec_loco.py
  • Added unit tests: tests/unit/data/datamodule/image/test_mvtec_loco.py
  • Updated necessary __init__.py files to expose new modules
  • Enhanced test helpers in tests/helpers/data.py

Example Usage

Here's how to use the MVTec LOCO dataset in your projects:

from anomalib.data import MVTecLOCO

# Basic usage with default settings
datamodule = MVTecLOCO(
    root="./datasets/MVTec_LOCO",
    category="breakfast_box",
)
datamodule.prepare_data()
datamodule.setup()

# Advanced configuration with custom settings
datamodule = MVTecLOCO(
    root="./datasets/MVTec_LOCO",
    category="juice_bottle",
    train_batch_size=32,
    eval_batch_size=32,
    num_workers=8,
    val_split_mode="from_test",  # Create validation set from test set
    val_split_ratio=0.5,  # Use 50% of test set for validation
)

# Using with a model
from anomalib.engine import Engine
from anomalib.models import Patchcore

model = Patchcore(backbone="wide_resnet50_2", layers=["layer3"], coreset_sampling_ratio=0.1)
engine = Engine()
engine.fit(model=model, datamodule=datamodule)
predictions = engine.predict(model=model, datamodule=datamodule)

The dataset supports 5 categories of industrial objects:

  • breakfast_box
  • juice_bottle
  • pushpins
  • screw_bag
  • splicing_connectors

Each category contains various types of logical and structural anomalies for training and testing.

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
lipemat Mat Lipe
Signed-off-by: Samet Akcay <[email protected]>
Copy link
Contributor

@ashwinvaidya17 ashwinvaidya17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@samet-akcay samet-akcay merged commit edcbb67 into openvinotoolkit:main Mar 21, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants