Skip to content

Release Anomalib Library v2.7.0

Choose a tag to compare

@ashwinvaidya17 ashwinvaidya17 released this 06 Oct 14:34
· 38 commits to main since this release
9fb1337

What's Changed

Added

Removed

  • ⚠️ breaking: Remove APIs scheduled for 2.7.0 — legacy ONNX exporter (dynamo=False; dynamo/onnxscript via anomalib[openvino] now required), restore_frozen_encoder_weights / pre-timm ViT checkpoint migration (retrain or re-export), and raise minimum PyTorch to >=2.10.0 (torchvision>=0.25.0 for cpu/cu/xpu; ROCm remains torch>=2.13.0) by @ashwinvaidya17 in #3826

Changed

  • ⚠️ security: When a dataset root is set, metadata path columns (Tabular and similar loaders) must resolve under that root; absolute paths outside root are rejected by @ashwinvaidya17 in #3794 and #3796
  • 🔧 model: Replace Sklearn with optimized PyTorch KMeans in CFA by @andersendsa in #3760
  • 🔧 deps: Require transformers>=4.40 to avoid resolver backtracking to 4.12 by @ashwinvaidya17 in #3840

Fixed

  • 🐞 metric: AUPR now computes step-wise average precision, so constant, all-zero and inverted detectors score at the anomaly rate instead of 0.525 by @mateenali66 in #3797
  • 🐞 metric: Fix thresholds_between_min_and_max device fallback when device is None by @andersendsa in #3807
  • 🐞 callbacks: Make MaxStepsProgressCallback picklable during checkpointing by @jrusbo in #3799
  • 🐞 model: Fix SuperADD's asynchronous CPU copy corrupting stored embeddings by @rajeshgangireddy in #3827
  • 🐞 model: Make models exportable with the dynamo ONNX exporter by @ashwinvaidya17 in #3834
  • 🐞 model: Decode CFlow rows in one pass when exporting by @ashwinvaidya17 in #3836
  • 🔒 deps: Upgrade the ROCm installation extra to PyTorch 2.13 or later on ROCm 7.2 by @AlexanderBarabanov in #3820
  • 🔒 security: Checkpoint loading now defaults to weights_only=True, blocking arbitrary code execution from untrusted .ckpt. Checkpoints saved before this change that pickled live component objects in hyper_parameters will fail to load; pass weights_only=False once to migrate, or re-save under the new format. Custom PreProcessor subclasses and non-default Evaluator / Visualizer instances are not reconstructed automatically — pass them to load_from_checkpoint(...) (and override checkpoint_config / load_checkpoint_config for custom pre/post-processors) by @ashwinvaidya17 in #3801
  • 📚 docs: remove retired HPO references from README and how-to index by @kuotunyu in #3808

New Contributors

Full Changelog: lib/v2.6.2...lib/v2.7.0


API Changes

v2.7.0 removes the legacy ONNX exporter and pre-timm ViT checkpoint migration, raises the minimum PyTorch version, and changes several security-sensitive defaults. New models: MHPatchcore, Rad, and FoundAD.

At a glance

Kind Change What to do
Removed Legacy ONNX exporter (dynamo=False) Use dynamo=True (default); install anomalib[openvino] for onnxscript
Removed restore_frozen_encoder_weights / pre-timm ViT checkpoint loading Retrain or re-export under a current release
Removed PyTorch <2.10 on cpu/cu/xpu extras Upgrade to torch>=2.10.0 (ROCm: >=2.13.0)
Changed Checkpoint load defaults to weights_only=True Migrate old checkpoints once with weights_only=False, or pass custom components into load_from_checkpoint
Changed Dataset root path hardening Ensure metadata paths resolve under root
Changed AUPR scoring Expect step-wise average precision (edge-case scores may change)
Added MHPatchcore from anomalib.models import MHPatchcore
Added Rad from anomalib.models import Rad
Added FoundAD from anomalib.models import FoundAD

Removed

Legacy ONNX exporter (dynamo=False)

  • Module: anomalib.models.components.base.export_mixin
  • Deprecated since: v2.5.1
  • Why: Torch’s dynamo-based exporter is required; the legacy path was removed in v2.7.0.
# Before (no longer works)
model.to_onnx(export_root="./exports", dynamo=False)

# After (default)
# pip install "anomalib[openvino]"  # provides onnxscript
model.to_onnx(export_root="./exports")  # dynamo=True
# or explicitly:
model.to_onnx(export_root="./exports", dynamo=True)

Pre-timm ViT checkpoint migration (restore_frozen_encoder_weights)

  • Module: previously anomalib.models.components.base.restore_frozen_encoder_weights
  • Deprecated since: v2.5.0
  • Why: Loading Vision Transformer checkpoints trained before the timm-encoder migration is no longer supported.
# Before: dinomaly / inp_former / anomaly_dino / patchflow / l2bt
# automatically rewrote legacy encoder keys in on_load_checkpoint

# After: retrain, or export/re-save a checkpoint under anomalib >= 2.5
# with the timm-based encoder layout, then load that checkpoint

Minimum PyTorch >=2.10.0

  • Module: install extras (cpu, cu126, cu130, xpu); ROCm remains torch>=2.13.0
  • Why: Announced with the ONNX dynamo deprecation; required for the dynamo exporter path.
# Before
pip install "anomalib[cpu]"   # allowed torch>=2.6

# After
pip install "anomalib[cpu]"   # requires torch>=2.10, torchvision>=0.25
# ROCm
pip install "anomalib[rocm]"  # requires torch>=2.13

Changed

Checkpoint loading defaults to weights_only=True

  • Impact: Untrusted .ckpt files can no longer execute arbitrary code via pickle. Checkpoints that pickled live component objects in hyper_parameters fail to load until migrated. Custom PreProcessor subclasses and non-default Evaluator / Visualizer instances are not reconstructed automatically.
  • PR: #3801
# Migrate an old checkpoint once (trusted file only), then re-save
model = MyModel.load_from_checkpoint("old.ckpt", weights_only=False)
# ... or pass custom components explicitly:
model = MyModel.load_from_checkpoint(
    "model.ckpt",
    pre_processor=MyPreProcessor(),
    evaluator=my_evaluator,
    visualizer=my_visualizer,
)

Dataset root path hardening

  • Impact: When a dataset root is set, metadata path columns (Tabular and similar loaders) must resolve under that root; absolute paths outside root are rejected.
  • PR: #3794, #3796
# Paths in metadata must stay under root
datamodule = Tabular(
    name="custom",
    samples=samples,  # path columns relative to / under root
    root="./datasets/custom",
)

AUPR uses step-wise average precision

  • Impact: Constant, all-zero, and inverted detectors score at the anomaly rate instead of a misleading mid-range value (previously ~0.525 in some cases).
  • PR: #3797

Added

MHPatchcore

  • Import: from anomalib.models import MHPatchcore
  • PR: #3809
from anomalib.data import MVTecAD
from anomalib.engine import Engine
from anomalib.models import MHPatchcore

datamodule = MVTecAD()
model = MHPatchcore()
engine = Engine()
engine.fit(model=model, datamodule=datamodule)

Rad

  • Import: from anomalib.models import Rad
  • PR: #3721
from anomalib.data import MVTecAD
from anomalib.engine import Engine
from anomalib.models import Rad

datamodule = MVTecAD()
model = Rad()
engine = Engine()
engine.fit(model=model, datamodule=datamodule)

FoundAD

  • Import: from anomalib.models import FoundAD
  • PR: #3793
from anomalib.data import MVTecAD
from anomalib.engine import Engine
from anomalib.models import FoundAD

datamodule = MVTecAD()
model = FoundAD()
engine = Engine()
engine.fit(model=model, datamodule=datamodule)

What's Changed

New Contributors

Full Changelog: lib/v2.6.2...lib/v2.7.0