SkillAgentSearch skills...

Anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.

Install / Use

/learn @open-edge-platform/Anomalib

README

<div align="center"> <img src="https://raw.githubusercontent.com/open-edge-platform/anomalib/main/docs/source/_static/images/logos/anomalib-wide-blue.png" width="600px" alt="Anomalib Logo - A deep learning library for anomaly detection">

A library for benchmarking, developing and deploying deep learning anomaly detection algorithms


Key FeaturesDocsNotebooksLicense

python pytorch lightning openvino

Pre-Merge Checks codecov Downloads snyk OpenSSF Best Practices

ReadTheDocs Anomalib - Gurubase docs

<a href="https://trendshift.io/repositories/6030" target="_blank"><img src="https://trendshift.io/api/badge/repositories/6030" alt="open-edge-platform%2Fanomalib | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>

</div>

🌟 Announcing v2.3.0 Release! 🌟

We're thrilled to announce the release of Anomalib v2.3.0, featuring new models and many quality-of-life improvements! Some of the highlights are: New models

  • AnomalyDINO : A new anomaly detection model leveraging DINOv2 features.
  • SuperSimpleNet : Updated to the latest version with improved performance.

New features

  • PatchCore half-precision : Support for FP16 training, reducing memory usage.
  • Barebones Engine mode : A simplified engine mode for lightweight workflows.
  • Kaput dataset : A new dataset for anomaly detection benchmarking.
  • XPU device support : Intel XPU support in TorchInferencer for accelerated inference.

Bug fixes

  • Fixed PatchCore GPU memory bottleneck (kNN) during inference.
  • Fixed F1AdaptiveThreshold bug when no anomalous images are in the validation set.
  • Fixed support for non-square input images in Dinomaly model.
  • Fixed INT8_PTQ and INT8_ACQ export issues.
  • Improved Windows path compatibility.
  • Many more code and documentation updates.

We value your input! Please share feedback via GitHub Issues or our Discussions

👋 Introduction

Anomalib is a deep learning library that aims to collect state-of-the-art anomaly detection algorithms for benchmarking on both public and private datasets. Anomalib provides several ready-to-use implementations of anomaly detection algorithms described in the recent literature, as well as a set of tools that facilitate the development and implementation of custom models. The library has a strong focus on visual anomaly detection, where the goal of the algorithm is to detect and/or localize anomalies within images or videos in a dataset. Anomalib is constantly updated with new algorithms and training/inference extensions, so keep checking!

<p align="center"> <img src="https://raw.githubusercontent.com/open-edge-platform/anomalib/main/docs/source/_static/images/readme.png" width="1000" alt="A prediction made by anomalib"> </p>

Key features

  • Simple and modular API and CLI for training, inference, benchmarking, and hyperparameter optimization.
  • The largest public collection of ready-to-use deep learning anomaly detection algorithms and benchmark datasets.
  • Lightning based model implementations to reduce boilerplate code and limit the implementation efforts to the bare essentials.
  • The majority of models can be exported to OpenVINO Intermediate Representation (IR) for accelerated inference on Intel hardware.
  • A set of inference tools for quick and easy deployment of the standard or custom anomaly detection models.

📦 Installation

Anomalib can be installed from PyPI. We recommend using a virtual environment and a modern package installer like uv or pip.

🚀 Quick Install

For a standard installation, you can use uv or pip. This will install the latest version of Anomalib with its core dependencies. PyTorch will be installed based on its default behavior, which usually works for CPU and standard CUDA setups.

# With uv
uv pip install anomalib

# Or with pip
pip install anomalib

For more control over the installation, such as specifying the PyTorch backend (e.g., XPU, CUDA and ROCm) or installing extra dependencies for specific models, see the advanced options below.

<details> <summary><strong>💡 Advanced Installation: Specify Hardware Backend</strong></summary>

To ensure compatibility with your hardware, you can specify a backend during installation. This is the recommended approach for production environments and for hardware other than CPU or standard CUDA.

Using uv:

# CPU support (default, works on all platforms)
uv pip install "anomalib[cpu]"

# CUDA 12.6 support (Linux/Windows with NVIDIA GPU)
uv pip install "anomalib[cu126]"

# CUDA 12.4 support (Linux/Windows with NVIDIA GPU)
uv pip install "anomalib[cu124]"

# CUDA 11.8 support (Linux/Windows with NVIDIA GPU)
uv pip install "anomalib[cu118]"

# ROCm support (Linux with AMD GPU)
uv pip install "anomalib[rocm]"

# Intel XPU support (Linux with Intel GPU)
uv pip install "anomalib[xpu]"

Using pip: The same extras can be used with pip:

pip install "anomalib[cu124]"
</details> <details> <summary><strong>🧩 Advanced Installation: Additional Dependencies</strong></summary>

Anomalib includes most dependencies by default. For specialized features, you may need additional optional dependencies. Remember to include your hardware-specific extra.

# Example: Install with OpenVINO support and CUDA 12.4
uv pip install "anomalib[openvino,cu124]"

# Example: Install all optional dependencies for a CPU-only setup
uv pip install "anomalib[full,cpu]"

Here is a list of available optional dependency groups:

| Extra | Description | Purpose | | :------------ | :--------------------------------------- | :------------------------------------------ | | [openvino] | Intel OpenVINO optimization | For accelerated inference on Intel hardware | | [clip] | Vision-language models | winclip | | [vlm] | Vision-language model backends | Advanced VLM features | | [loggers] | Experiment tracking (wandb, comet, etc.) | For experiment management | | [notebooks] | Jupyter notebook support | For running example notebooks | | [full] | All optional dependencies | All optional features |

</details> <details> <summary><strong>🔧 Advanced Installation: Install from Source</strong></summary>

For contributing to anomalib or using a development version, you can install from source.

Using uv: This is the recommended method for developers as it uses the project's lock file for reproducible environments.

git clone https://github.com/open-edge-platform/anomalib.git
cd anomalib

# Create the virtual environment
uv venv

# Sync with the lockfile for a specific backend (e.g., CPU)
uv sync --extra cpu

# Or for a different backend like CUDA 12.4
uv sync --extra cu124

# To set up a full development environment
uv sync --extra dev --extra cpu

Using pip:

git clone https://github.com/open-edge-platform/anomalib.git
cd anomalib

# Install in editable mode with a specific backend
pip install -e ".[cpu]"

# Install with development dependencies
pip install -e ".[dev,cpu]"
</details>

🧠 Training

Anomalib supports both API and CLI-based training approaches:

🔌 Python API

from anomalib.data import MVTecAD
from anomalib.models import Patchcore
from anomalib.engine import Engine

# Initialize components
datamodule = MVTecAD()
model = Patchcore()
engine = Engine()

# Train the model
engine.fit(datamodule=datamodule, model=model)

⌨️ Command Line

# Train with default settings
anomalib train --model Patchcore --data anomalib.data.MVTecAD

# Train with custom category
anomalib train --model Patchcore --data anomalib.data.MVTecAD --data.category transistor

# Train with config file
anomalib train --config path/to/config.yaml

🤖 Inference

Anomalib provides multiple inference options including Torch, Lightning, Gradio, and OpenVINO. Here's how to get started:

🔌 Python API

# Load model and make predictions
predictions = engine.predict(
    datamodule=datamodule,
    model=model,
    ckpt_path="path/to/checkpoint.ckpt",
)

⌨️ Command Line

# Basic prediction
anomalib predict --model a
View on GitHub
GitHub Stars5.5k
CategoryEducation
Updated16h ago
Forks899

Languages

Python

Security Score

100/100

Audited on Mar 21, 2026

No findings