Writing Skills
writing-skills
效率与协作技能,来自 obra/superpowers,查看原文获取完整用途和操作说明。
deployment-and-inference【部署与运维】Export trained anomalib models and run runtime inference with Engine.predict, export helpers, TorchInferencer, and OpenVINOInferencer.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
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.
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.| 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. |
AnomalibModule or a trusted exported checkpoint.Engine.predict)Engine.export / ExportMixin)TorchInferencer or OpenVINOInferencer)torch for a pickled model objectonnx for interchange or downstream conversionopenvino for optimized deploymentonnxscript must be installed. For OpenVINO INT8 export, nncf must be installed.FP16 or INT8 when you do not have a datamoduleINT8_PTQ or INT8_ACQ only with a datamoduleINT8_ACQ with a metric when you need custom quality controlscripts/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.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.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.weights/torch/model.pt.weights/onnx/model.onnx.weights/openvino/model.xml with a sibling .bin.Engine.predict can be driven by dataset, datamodule, or data_path.