Agent skill

Anomalib Adding A Model

by open-edge-platform in open-edge-platform/anomalib

Adds a new anomaly-detection model to anomalib under src/anomalib/models/.

Apache-2.0Auto-check passedData & Analytics

Install Anomalib Adding A Model

skills CLI
$ npx skills add open-edge-platform/anomalib --skill anomalib-adding-a-model -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install open-edge-platform/anomalib anomalib-adding-a-model --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/open-edge-platform/anomalib.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/anomalib-adding-a-model .claude/skills/anomalib-adding-a-model && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
anomalib-adding-a-model
GitHub stars
6.2k
Token cost
~1.9k tokens
SKILL.md length
543 words
Files
2
Skills in repo
17
Repo updated
First seen
Licence
Apache-2.0

At a glance

Adds a new anomaly-detection model to anomalib under src/anomalib/models/.

  • Works in 5 steps: Add the export in… → Also add the import in… → That's the only registration needed.… → …
  • Implementing a new model architecture (image
  • SKILL.md covers Reference implementation, Required members on your…, Registration — how the model… and Tests, plus 2 more sections
  • Calls pytest

What it does

Anomalib Adding A Model is an agent skill from open-edge-platform/anomalib. Adds a new anomaly-detection model to anomalib under src/anomalib/models/. Use when implementing a new model architecture (image or video), wiring it into the AnomalibModule base class, registering it so getmodel() and the CLI/config (jsonargparse) can discover it, and adding matching tests. Do not use for changes to existing model internals only (no new model), or for datamodule/dataset work (see anomalib-adding-a-datamodule).

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `evals/evals.json`).

It sits in Data & Analytics, covering Anomaly detection and AI interpretability. The repository describes itself as: An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference. The licence is Apache-2.0.

When your agent uses it

  • Implementing a new model architecture (image
  • Wiring it into the AnomalibModule base class
  • Registering it so getmodel() and the CLI/config (jsonargparse) can discover it
  • Adding matching tests

Example prompts

  • “/anomalib-adding-a-model”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Add the export in src/anomalib/models/image/init.py (or video/init.py)
  2. Also add the import in src/anomalib/models/init.py, which explicitly imports all image (and
  3. That's the only registration needed. list_models() and get_model()
  4. get_model() also accepts a dict/DictConfig/Namespace with class_path + init_args, restricted to
  5. Once exported, the model is usable as anomalib.models.MyModel, from get_model("MyModel"), and from the

What it can do on your machine

Read from SKILL.md and the folder at commit 4807ef1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pytest

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Anomalib Adding A Model loads about 1.9k tokens when it runs. Until then it costs about 114 tokens; SKILL.md has 543 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~114
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from open-edge-platform/anomalib at commit 4807ef1, republished under its Apache-2.0 licence (© open-edge-platform). 543 words, ~1,896 tokens.

Download SKILL.mdSave it as .claude/skills/anomalib-adding-a-model/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
anomalib-adding-a-model
description
Adds a new anomaly-detection model to anomalib under src/anomalib/models/. Use when implementing a new model architecture (image or video), wiring it into the AnomalibModule base class, registering it so get_model() and the CLI/config (jsonargparse) can discover it, and adding matching tests. Do not use for changes to existing model internals only (no new model), or for datamodule/dataset work (see anomalib-adding-a-datamodule).
license
Apache-2.0

Adding a New Model

Models live under src/anomalib/models/image/<model_name>/ (or .../video/<model_name>/ for video models). Every model is a LightningModule subclass of AnomalibModule (src/anomalib/models/components/base/anomalib_module.py) that wraps a plain torch.nn.Module.

Reference implementation

Read src/anomalib/models/image/padim/ first — it is the smallest complete example:

  • torch_model.py — PadimModel(nn.Module): pure PyTorch forward pass. In training mode it returns intermediate embeddings; in eval mode it returns an InferenceBatch(pred_score=..., anomaly_map=...).
  • anomaly_map.py — AnomalyMapGenerator(nn.Module): post-processing (score/map computation) kept out of torch_model.py for clarity. Not all models need a separate file for this.
  • lightning_model.py — Padim(MemoryBankMixin, AnomalibModule): the Lightning-facing wrapper. This is the class users construct (Padim()), pass to Engine, and reference from CLI/config as anomalib.models.Padim.
  • __init__.py — exports the Lightning class only: from .lightning_model import Padim.
  • README.md — usage + benchmark notes (see model-doc-sync/model-sample-image-export skills for docs work).

Only mix in MemoryBankMixin (src/anomalib/models/components/base/memory_bank_module.py) if the model accumulates a memory bank / feature bank across training (as PaDiM and PatchCore do). Most models just subclass AnomalibModule directly.

Required members on your AnomalibModule subclass

python
import torch
from anomalib import LearningType
from anomalib.data import Batch
from anomalib.metrics import Evaluator
from anomalib.models.components import AnomalibModule
from anomalib.post_processing import PostProcessor
from anomalib.pre_processing import PreProcessor
from anomalib.visualization import Visualizer

class MyModel(AnomalibModule):
    def __init__(self, some_param: int = 1, pre_processor: PreProcessor | bool = True,
                 post_processor: PostProcessor | bool = True,
                 evaluator: Evaluator | bool = True,
                 visualizer: Visualizer | bool = True) -> None:
        super().__init__(pre_processor=pre_processor, post_processor=post_processor,
                          evaluator=evaluator, visualizer=visualizer)
        self.model = MyTorchModel(some_param=some_param)

    @property
    def trainer_arguments(self) -> dict:
        """Default Trainer overrides for this model, e.g. {"max_epochs": 1} for training-free models."""
        return {"max_epochs": 1, "num_sanity_val_steps": 0}

    @property
    def learning_type(self) -> LearningType:
        return LearningType.ONE_CLASS

    def training_step(self, batch: Batch, *args, **kwargs) -> torch.Tensor:
        # Training-free models (e.g. Padim) still return a dummy loss for Lightning.
        _ = self.model(batch.image)
        return torch.tensor(0.0, requires_grad=True, device=self.device)

    def validation_step(self, batch: Batch, *args, **kwargs) -> Batch:
        predictions = self.model(batch.image)
        return batch.update(**predictions._asdict())

    def configure_optimizers(self) -> None:
        # Return None for training-free / statistical models (Padim does this).
        return None

AnomalibModule provides working defaults you can override only when the model needs something different:

  • configure_pre_processor(image_size=None) — resize + ImageNet normalization.
  • configure_post_processor() — thresholding/normalization for ONE_CLASS models.
  • configure_evaluator() — image/pixel AUROC and F1 metrics.
  • configure_visualizer() — default ImageVisualizer.

pre_processor / post_processor / evaluator / visualizer constructor args each accept an instance, True (use the configured default), or False (disable).

Registration — how the model becomes discoverable

  1. Add the export in src/anomalib/models/image/__init__.py (or video/__init__.py):

    python
    from .my_model import MyModel

    and add "MyModel" to __all__ and to the Available Models docstring list at the top of the file.

  2. Also add the import in src/anomalib/models/__init__.py, which explicitly imports all image (and video) models and defines the top-level __all__. Without this, anomalib.models.MyModel won't resolve.

  3. That's the only registration needed. list_models() and get_model() (src/anomalib/models/__init__.py) discover models by walking AnomalibModule.__subclasses__() and matching on cls.__name__ (case-insensitive) — there is no separate name-string registry to update.

  4. get_model() also accepts a dict/DictConfig/Namespace with class_path + init_args, restricted to modules listed in ALLOWED_MODULES (same file) — you don't need to touch that set for models already under anomalib.models.

  5. Once exported, the model is usable as anomalib.models.MyModel, from get_model("MyModel"), and from the CLI: anomalib train --model MyModel --data anomalib.data.MVTecAD.

Show full SKILL.md (204 more words)Show less

Tests

Add tests/unit/models/image/my_model/test_my_model.py (or .../video/my_model/...). At minimum:

  • get_model("MyModel") (and the equivalent PascalCase/snake_case variants) returns a MyModel instance.
  • model.trainer_arguments is a dict and model.learning_type is the expected LearningType.
  • A synthetic batch through training_step/validation_step produces the expected shapes: image-level pred_score has shape (batch_size,) and pixel-level anomaly_map has shape (batch_size, 1, H, W) without crashing.

See tests/unit/models/test_model_utils.py for the get_model() instantiation pattern used across the suite.

Gotchas

  • Keep torch_model.py importable and testable without Lightning — the nn.Module.forward contract (train-mode returns raw tensors/embeddings, eval-mode returns InferenceBatch) is what the base class and visualizers expect. Don't put Lightning-specific logic there.
  • Training side effects (checkpointing, timing, compression, visualization) belong in src/anomalib/callbacks/-style Lightning callbacks or existing hooks — not inline in the model's training_step.
  • Public constructor arguments must stay explicit and typed (no untyped **kwargs passthrough) so jsonargparse can expose them on the CLI/config surface.
  • If the model becomes part of the public API, update the model's README.md and, if one exists, the matching page under docs/source/markdown/guides/reference/models/.

Reviewer / self-check before opening a PR

  • Model exported from src/anomalib/models/image/__init__.py (or video/__init__.py) and __all__ updated.
  • trainer_arguments, learning_type, training_step, validation_step, configure_optimizers implemented.
  • get_model("MyModel") and anomalib.models.MyModel both resolve.
  • Unit tests added under tests/unit/models/.
  • README.md added in the model folder.
  • pre-commit run --all-files and pytest tests/unit/models/ -k my_model pass.

© open-edge-platform, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in .agents/skills/anomalib-adding-a-model of open-edge-platform/anomalib.

  • SKILL.md
  • evals/evals.json

Open the folder on GitHubat commit 4807ef1

Compare with similar skills

Anomalib Adding A Model next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Anomalib Adding A Model compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Anomalib Adding A Model this skillopen-edge-platform/anomalib6.2k—~1.9kAutomated safety check: PassApache-2.0
TimesFM Forecastinggoogle-research/timesfm34k—~4.7kAutomated safety check: PassApache-2.0
Sae Feature Annotationssoftnanolab/bagel148—~1.5kAutomated safety check: PassMIT
SHAP Model Explainabilitydavila7/claude-code-templates32k12 repos~4.6kAutomated safety check: PassMIT
Scholar Lingjoshzyj/open-scholar-skill167—~6.7kAutomated safety check: PassCustom licence
Tao Finetune Nv Tesseract Ad DiffusionNVIDIA/skills3.5k—~2.9kAutomated safety check: NotesApache-2.0

Similar skills

  • TimesFM Forecasting

    google-research/timesfm

    Forecasts any univariate time series zero-shot with Google's TimesFM model, returning point forecasts and calibrated prediction intervals without training.

    34k GitHub stars~4.7k tokensUpdated 7 days ago
    Data & AnalyticsAuto-check passed
  • Sae Feature Annotations

    softnanolab/bagel

    Look up what a Biohub ESM-C sparse-autoencoder (SAE) feature means — its label, description, top-activating proteins, decoder neighbours, and activation statistics — by querying the Biohub…

    148 GitHub stars~1.5k tokensUpdated today
    Data & AnalyticsAuto-check passed
  • SHAP Model Explainability

    davila7/claude-code-templates

    Explains machine learning predictions with SHAP: picking the right explainer, computing Shapley values and drawing waterfall, beeswarm, bar and force plots.

    32k GitHub starsUsed in 12 repos~4.6k tokens
    Data & AnalyticsAuto-check passed
  • Scholar Ling

    joshzyj/open-scholar-skill

    Design and analyze studies in sociolinguistics, language variation, acoustic phonetics, discourse analysis, language contact, and computational linguistics.

    167 GitHub stars~6.7k tokensUpdated 19 days ago
    Data & AnalyticsAuto-check passed
  • NV-Tesseract AD Diffusion — diffusion-based anomaly detection and fine-tuning for multivariate time series.

    3.5k GitHub stars~2.9k tokensUpdated today
    Data & AnalyticsAuto-check: notes
  • NV-Tesseract Forecasting — transformer-based multivariate time series forecasting with DARR (context-enhanced kNN retrieval), interpretability, and fine-tuning.

    3.5k GitHub stars~3.2k tokensUpdated today
    Data & AnalyticsAuto-check: notes

More from open-edge-platform/anomalib

All 17 skills in this repo
  • Anomalib Adding A Datamodule

    open-edge-platform/anomalib

    Adds a new dataset/datamodule to anomalib under src/anomalib/data/.

    6.2k GitHub stars~3.7k tokensUpdated today
    Auto-check passed
  • Anomalib Benchmarking

    open-edge-platform/anomalib

    Runs the anomalib benchmarking pipeline to train/evaluate a grid of model + dataset (+ category) combinations and collect metrics into a results CSV.

    6.2k GitHub stars~1k tokensUpdated today
    Auto-check passed
  • Anomalib Tiled Ensemble

    open-edge-platform/anomalib

    Runs and configures the anomalib tiled-ensemble pipeline, which trains/evaluates one model per image tile and merges results (with optional seam smoothing) for high-resolution anomaly detection.

    6.2k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Anomalib Training

    open-edge-platform/anomalib

    Trains an anomalib model on a dataset via the Python API or CLI, including training on a custom folder-structured dataset with the Folder datamodule.

    6.2k GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • Model Sample Image Export

    open-edge-platform/anomalib

    Export, validate, and publish model sample-result images into docs/source/images and reference them from README/docs pages.

    6.2k GitHub stars~874 tokensUpdated today
    Auto-check passed
  • UI Test Utils

    open-edge-platform/anomalib

    A skill your agent uses when writing or updating Anomalib Studio UI component or hook tests that need the shared render/renderHook helpers, React Router paths or parameters, React Query, theme…

    6.2k GitHub stars~1.3k tokensUpdated today
    Auto-check passed

Questions about Anomalib Adding A Model

What does Anomalib Adding A Model do?

Adds a new anomaly-detection model to anomalib under src/anomalib/models/. Anomalib Adding A Model is an agent skill from open-edge-platform/anomalib. Adds a new anomaly-detection model to anomalib under src/anomalib/models/.

When should I use Anomalib Adding A Model?

Anomalib Adding A Model fits situations like: implementing a new model architecture (image; wiring it into the AnomalibModule base class; registering it so getmodel() and the CLI/config (jsonargparse) can discover it; adding matching tests.

How do I install Anomalib Adding A Model in Claude Code?

Run `npx skills add open-edge-platform/anomalib --skill anomalib-adding-a-model -a claude-code`. Or copy the skill folder (.agents/skills/anomalib-adding-a-model in open-edge-platform/anomalib) into .claude/skills/anomalib-adding-a-model in your project. Claude Code loads it when a task matches its description.

How do I install Anomalib Adding A Model in Codex?

Run `npx skills add open-edge-platform/anomalib --skill anomalib-adding-a-model -a codex`. Or copy the skill folder (.agents/skills/anomalib-adding-a-model in open-edge-platform/anomalib) into .agents/skills/anomalib-adding-a-model in your project. Codex loads it when a task matches its description.

Can I use Anomalib Adding A Model in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add open-edge-platform/anomalib --skill anomalib-adding-a-model -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/anomalib-adding-a-model, .gemini/skills/anomalib-adding-a-model, .github/skills/anomalib-adding-a-model and .opencode/skills/anomalib-adding-a-model in your project.

What does Anomalib Adding A Model need to run?

Going by SKILL.md and its folder, Anomalib Adding A Model needs the command-line tools its instructions call (pytest). Our summary lists: Python 3.

Does Anomalib Adding A Model access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Anomalib Adding A Model safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Anomalib Adding A Model use?

Anomalib Adding A Model is published under the Apache-2.0 licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Anomalib Adding A Model use?

About 1.9k tokens (SKILL.md is roughly 7.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Anomalib Adding A Model?

Skills that share tags, products or a category with Anomalib Adding A Model: TimesFM Forecasting (google-research/timesfm, 34k stars), Sae Feature Annotations (softnanolab/bagel, 148 stars), SHAP Model Explainability (davila7/claude-code-templates, 32k stars) and Scholar Ling (joshzyj/open-scholar-skill, 167 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Anomalib Adding A Model?

open-edge-platform (a GitHub organization) maintains it in open-edge-platform/anomalib, which has 6,227 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on October 7, 2026.

Source: open-edge-platform/anomalib on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.