Skip to content
Back to skills

Deployment And Inference

ASecurity

"Export trained anomalib models and run runtime inference with

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
devopspythonrustapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill deployment-and-inference --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Deployment And Inference?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Deployment And Inference
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-deployment-and-inference/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-deployment-and-inference)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: deployment-and-inference
description: "Export trained anomalib models and run runtime inference with
  Engine.predict, export helpers, TorchInferencer, and OpenVINOInferencer."
metadata:
  disco-role: operating
license: Apache 2.0
disable-model-invocation: true
---

# Deployment and Inference

Use this skill when a trained anomalib model must be turned into a runtime artifact or run at inference time. It covers the path from checkpoint or trained model to export, runtime loading, and prediction.

## What this skill covers

- `Engine.predict(...)` for dataset, datamodule, `data_path`, or explicit dataloaders.
- `Engine.export(...)` and the underlying `ExportMixin` helpers.
- `TorchInferencer` for trusted Torch checkpoints.
- `OpenVINOInferencer` for OpenVINO IR or ONNX artifacts.
- Export and runtime troubleshooting for optional dependencies and trust gates.

## What this skill excludes

- Training loop internals, fit/test/validate logic, and callback design.
- Benchmark or pipeline orchestration.
- Studio application files and UI implementation details.

## Quick chooser

| Need | Use | Notes |
| --- | --- | --- |
| Predict from a trained model inside Lightning | `Engine.predict(...)` | Best default when you already have an `AnomalibModule`. |
| Export to Torch / ONNX / OpenVINO | `Engine.export(...)` or `ExportMixin` | `INT8_PTQ` and `INT8_ACQ` need a datamodule. |
| Load a trusted Torch checkpoint directly | `TorchInferencer` | Legacy, pickle-based, and gated by `TRUST_REMOTE_CODE`. |
| Load an OpenVINO or ONNX deployment artifact | `OpenVINOInferencer` | Default device is `AUTO`; `config` is optional. |

## Primary workflow

1. Start from a trained `AnomalibModule` or a trusted exported checkpoint.
2. Decide whether you need:
   - Lightning-managed prediction (`Engine.predict`)
   - an export artifact (`Engine.export` / `ExportMixin`)
   - direct runtime inference (`TorchInferencer` or `OpenVINOInferencer`)
3. Pick the export format:
   - `torch` for a pickled model object
   - `onnx` for interchange or downstream conversion
   - `openvino` for optimized deployment
4. For ONNX dynamo export, `onnxscript` must be installed. For OpenVINO INT8 export, `nncf` must be installed.
5. For OpenVINO quantization:
   - use `FP16` or `INT8` when you do not have a datamodule
   - use `INT8_PTQ` or `INT8_ACQ` only with a datamodule
   - use `INT8_ACQ` with a metric when you need custom quality control
6. Treat Torch checkpoints as trusted code only. If the source is not trusted, do not bypass the gate; prefer ONNX or OpenVINO instead.
7. Use the bundled scripts for tiny deterministic smoke runs.

## Bundled references

- [Deployment guide](references/deployment-and-inference.md)
- [API reference](references/api-reference.md)
- [Troubleshooting](references/troubleshooting.md)

## Bundled scripts

- `scripts/basic-inference-api.py` — minimal Python `Engine.predict` example.
- `scripts/basic-openvino-inference.py` — minimal OpenVINO API recipe.
- `scripts/lightning-inference.py` — CLI-style `Engine.predict` helper.
- `scripts/openvino-inference.py` — OpenVINO image inference helper.
- `scripts/torch-inference.py` — legacy Torch inference helper with trust warning.

## Notes for future agents

- Prefer `Engine.predict` over `TorchInferencer` for new work.
- `TorchInferencer` loads pickled checkpoints and requires `TRUST_REMOTE_CODE=1`.
- `OpenVINOInferencer` accepts `.xml`, `.bin`, or `.onnx` paths and may create `openvino_cache/` in the current working directory.
- The repo's `basic_torch_inference.py` example is only a header stub in this checkout; do not depend on it.
- `tools/inference/gradio_inference.py` is reference-only because it launches a server and depends on optional UI packages.

## Minimal success checks

- Exported Torch artifact ends in `weights/torch/model.pt`.
- Exported ONNX artifact ends in `weights/onnx/model.onnx`.
- Exported OpenVINO artifact ends in `weights/openvino/model.xml` with a sibling `.bin`.
- `Engine.predict` can be driven by `dataset`, `datamodule`, or `data_path`.
- OpenVINO INT8 export is rejected until a datamodule is provided.
- Torch checkpoint loading is rejected until the trust gate is explicitly opened for a trusted file.

Files in this skill

  • SKILL.md4.1 KB
  • references/api-reference.md2.9 KB
  • references/deployment-and-inference.md3.6 KB
  • references/troubleshooting.md2.9 KB
  • scripts/basic-inference-api.py1.1 KB
  • scripts/basic-openvino-inference.py938 B
  • scripts/lightning-inference.py2.1 KB
  • scripts/openvino-inference.py4 KB
  • scripts/torch-inference.py3.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…