Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

open-edge-platform/anomalib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Anomalib Logo - A deep learning library for anomaly detection

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


Key FeaturesDocsNotebooksLicense

pythonpytorchlightningopenvino

Pre-Merge CheckscodecovDownloadssnyk

ReadTheDocsAnomalib - Gurubase docs

open-edge-platform%2Fanomalib | Trendshift


🌟Announcing v2.0.0 Release! 🌟

We're excited to announce the release of Anomalib v2.0.0! This version introduces significant improvements and customization options to enhance your anomaly detection workflows. Please be aware that there are several API changes betweenv1.2.0 andv2.0.0, so please be careful when updating your existing pipelines. Key features include:

We value your input! Please share feedback viaGitHub Issues or ourDiscussions

👋 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!

A prediction made by anomalib

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 toOpenVINO Intermediate Representation (IR) for accelerated inference on Intel hardware.
  • A set ofinference 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 likeuv orpip.

🚀 Quick Install

For a standard installation, you can useuv orpip. 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 uvuv pip install anomalib# Or with pippip 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.

💡 Advanced Installation: Specify Hardware Backend

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.

Usinguv:

# CPU support (default, works on all platforms)uv pip install"anomalib[cpu]"# CUDA 12.4 support (Linux/Windows with NVIDIA GPU)uv pip install"anomalib[cu124]"# CUDA 12.1 support (Linux/Windows with NVIDIA GPU)uv pip install"anomalib[cu121]"# 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]"

Usingpip:The same extras can be used withpip:

pip install"anomalib[cu124]"
🧩 Advanced Installation: Additional Dependencies

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.4uv pip install"anomalib[openvino,cu124]"# Example: Install all optional dependencies for a CPU-only setupuv pip install"anomalib[full,cpu]"

Here is a list of available optional dependency groups:

ExtraDescriptionPurpose
[openvino]Intel OpenVINO optimizationFor accelerated inference on Intel hardware
[clip]Vision-language modelswinclip
[vlm]Vision-language model backendsAdvanced VLM features
[loggers]Experiment tracking (wandb, comet, etc.)For experiment management
[notebooks]Jupyter notebook supportFor running example notebooks
[full]All optional dependenciesAll optional features
🔧 Advanced Installation: Install from Source

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

Usinguv: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.gitcd anomalib# Create the virtual environmentuv venv# Sync with the lockfile for a specific backend (e.g., CPU)uv sync --extra cpu# Or for a different backend like CUDA 12.4uv sync --extra cu124# To set up a full development environmentuv sync --extra dev --extra cpu

Usingpip:

git clone https://github.com/open-edge-platform/anomalib.gitcd anomalib# Install in editable mode with a specific backendpip install -e".[cpu]"# Install with development dependenciespip install -e".[dev,cpu]"

🧠 Training

Anomalib supports both API and CLI-based training approaches:

🔌 Python API

fromanomalib.dataimportMVTecADfromanomalib.modelsimportPatchcorefromanomalib.engineimportEngine# Initialize componentsdatamodule=MVTecAD()model=Patchcore()engine=Engine()# Train the modelengine.fit(datamodule=datamodule,model=model)

⌨️ Command Line

# Train with default settingsanomalib train --model Patchcore --data anomalib.data.MVTecAD# Train with custom categoryanomalib train --model Patchcore --data anomalib.data.MVTecAD --data.category transistor# Train with config fileanomalib 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 predictionspredictions=engine.predict(datamodule=datamodule,model=model,ckpt_path="path/to/checkpoint.ckpt",)

⌨️ Command Line

# Basic predictionanomalib predict --model anomalib.models.Patchcore \                 --data anomalib.data.MVTecAD \                 --ckpt_path path/to/model.ckpt# Prediction with resultsanomalib predict --model anomalib.models.Patchcore \                 --data anomalib.data.MVTecAD \                 --ckpt_path path/to/model.ckpt \                 --return_predictions

📘Note: For advanced inference options including Gradio and OpenVINO, check ourInference Documentation.

Training on Intel GPUs

Note

Currently, only single GPU training is supported on Intel GPUs.These commands were tested on Arc 750 and Arc 770.

Ensure that you have PyTorch with XPU support installed. For more information, please refer to thePyTorch XPU documentation

🔌 API

fromanomalib.dataimportMVTecADfromanomalib.engineimportEngine,SingleXPUStrategy,XPUAcceleratorfromanomalib.modelsimportStfpmengine=Engine(strategy=SingleXPUStrategy(),accelerator=XPUAccelerator(),)engine.train(Stfpm(),datamodule=MVTecAD())

⌨️ CLI

anomalib train --model Padim --data MVTecAD --trainer.accelerator xpu --trainer.strategy xpu_single

⚙️ Hyperparameter Optimization

Anomalib supports hyperparameter optimization (HPO) usingWeights & Biases andComet.ml.

# Run HPO with Weights & Biasesanomalib hpo --backend WANDB --sweep_config tools/hpo/configs/wandb.yaml

📘Note: For detailed HPO configuration, check ourHPO Documentation.

🧪 Experiment Management

Track your experiments with popular logging platforms throughPyTorch Lightning loggers:

  • 📊 Weights & Biases
  • 📈 Comet.ml
  • 📉 TensorBoard

Enable logging in your config file to track:

  • Hyperparameters
  • Metrics
  • Model graphs
  • Test predictions

📘Note: For logging setup, see ourLogging Documentation.

📊 Benchmarking

Evaluate and compare model performance across different datasets:

# Run benchmarking with default configurationanomalib benchmark --config tools/experimental/benchmarking/sample.yaml

💡Tip: Check individual model performance in their respective README files:

✍️ Reference

If you find Anomalib useful in your research or work, please cite:

@inproceedings{akcay2022anomalib,  title={Anomalib: A deep learning library for anomaly detection},  author={Akcay, Samet and Ameln, Dick and Vaidya, Ashwin and Lakshmanan, Barath and Ahuja, Nilesh and Genc, Utku},  booktitle={2022 IEEE International Conference on Image Processing (ICIP)},  pages={1706--1710},  year={2022},  organization={IEEE}}

👥 Contributing

We welcome contributions! Check out ourContributing Guide to get started.

Contributors to open-edge-platform/anomalib

Thank you to all our contributors!

About

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

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp