Repository navigation
Release Anomalib Library v2.7.0
·
38 commits
to main
since this release
What's Changed
Added
- 🚀 model: Add MH-PatchCore by @NickF93 in #3809
- 🚀 model: Add RAD (Retrieval-based Anomaly Detection) model by @josselinonduty in #3721
- 🚀 model: Add FoundAD Few Shot Anomaly Detection Model by @rajeshgangireddy in #3793
Removed
⚠️ breaking: Remove APIs scheduled for 2.7.0 — legacy ONNX exporter (dynamo=False; dynamo/onnxscriptviaanomalib[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.0for cpu/cu/xpu; ROCm remainstorch>=2.13.0) by @ashwinvaidya17 in #3826
Changed
⚠️ security: When a datasetrootis set, metadata path columns (Tabular and similar loaders) must resolve under that root; absolute paths outsiderootare rejected by @ashwinvaidya17 in #3794 and #3796- 🔧 model: Replace Sklearn with optimized PyTorch KMeans in CFA by @andersendsa in #3760
- 🔧 deps: Require
transformers>=4.40to avoid resolver backtracking to 4.12 by @ashwinvaidya17 in #3840
Fixed
- 🐞 metric:
AUPRnow 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_maxdevice fallback whendeviceisNoneby @andersendsa in #3807 - 🐞 callbacks: Make
MaxStepsProgressCallbackpicklable 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 inhyper_parameterswill fail to load; passweights_only=Falseonce to migrate, or re-save under the new format. CustomPreProcessorsubclasses and non-defaultEvaluator/Visualizerinstances are not reconstructed automatically — pass them toload_from_checkpoint(...)(and overridecheckpoint_config/load_checkpoint_configfor 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
- @NickF93 made their first contribution in #3809
- @josselinonduty made their first contribution in #3721
- @kuotunyu made their first contribution in #3808
- @jrusbo made their first contribution in #3799
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 checkpointMinimum PyTorch >=2.10.0
- Module: install extras (
cpu,cu126,cu130,xpu); ROCm remainstorch>=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.13Changed
Checkpoint loading defaults to weights_only=True
- Impact: Untrusted
.ckptfiles can no longer execute arbitrary code via pickle. Checkpoints that pickled live component objects inhyper_parametersfail to load until migrated. CustomPreProcessorsubclasses and non-defaultEvaluator/Visualizerinstances 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
rootis set, metadata path columns (Tabular and similar loaders) must resolve under that root; absolute paths outsiderootare 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
- chore(lib): bump to dev by @ashwinvaidya17 in #3791
- fix(data): harden path checks by @ashwinvaidya17 in #3794
- fix(data): address remaining path issues by @ashwinvaidya17 in #3796
- chore(deps): lock file maintenance by @oep-renovate[bot] in #3795
- chore(ci): remove opencode actions to avoid GPU OOM by @ashwinvaidya17 in #3802
- chore(copilot): update review instructions by @ashwinvaidya17 in #3803
- fix(deps): npm audit fixes [security] by @oep-renovate[bot] in #3805
- chore(docs): update docs by @ashwinvaidya17 in #3806
- docs: remove retired HPO references from README and how-to index by @kuotunyu in #3808
- refactor(tests): reduce test time by @ashwinvaidya17 in #3818
- ci(test): enable pytest-xdist on CPU CI by @ashwinvaidya17 in #3817
- perf(model): Replace Sklearn with optimized PyTorch KMeans in CFA by @andersendsa in #3760
- fix(weights): change how models are serialized and deserialized by @ashwinvaidya17 in #3801
- fix(deps): npm audit fixes [security] by @oep-renovate[bot] in #3814
- fix(callbacks): make MaxStepsProgressCallback picklable during checkpointing by @jrusbo in #3799
- fix(metric): fix thresholds_between_min_and_max device fallback by @andersendsa in #3807
- chore(deps): upgrade the ROCm installation extra to torch>=2.13.0 by @AlexanderBarabanov in #3820
- fix(super-add): synchronize embedding host copies by @rajeshgangireddy in #3827
- chore(deps): update github actions by @oep-renovate[bot] in #3829
- chore(deps): update dependency notebook to v7.6.3 [security] by @oep-renovate[bot] in #3833
- chore(deps): update dependency dompurify to v3.4.16 [security] by @oep-renovate[bot] in #3828
- chore(lib): prep v2.7.0 release by @ashwinvaidya17 in #3823
- ci: Pin geti-ci actions in workflows by @ivanzati in #3831
New Contributors
Full Changelog: lib/v2.6.2...lib/v2.7.0