Docs /Templates/ sinapsis-anomalib

AnomalibTorchInference

sinapsis-anomalibAnomalibanomalibanomaly_detectioninferencemodels

Python template · sinapsis_anomalib.templates.anomalib_torch_inference

Overview

PyTorch-specific inference implementation for Anomalib models.

Extends base inference to provide native PyTorch model execution.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-anomalib==1.0.0
uv pip install sinapsis-anomalib==1.0.0
uv add sinapsis-anomalib==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

deviceRequired

Target device for inference (either 'cuda' or 'cpu').

typing.Literal['cuda', 'cpu']
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
model_pathRequired
str
Required
Default: null
transforms
dict
Optional
Default: null
anomaly_area_threshold
float
Optional
Default: 100

Configuration example

Example from the Python docstring:

yaml
agent:
    name: my_test_agent
    templates:
    - template_name: InputTemplate
    class_name: InputTemplate
    attributes: {}
    - template_name: AnomalibTorchInference
    class_name: AnomalibTorchInference
    template_input: InputTemplate
    attributes:
        model_path: 'path/to/model.pt'
        transforms: null
        device: 'cuda'
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "AnomalibTorchInference"
    class_name: "AnomalibTorchInference"
    attributes:
      device: "<required>"
      model_path: "<required>"
      transforms: {}
      anomaly_area_threshold: 100

Inheritance

Immediate parent: sinapsis_anomalib.templates.anomalib_base_inference.AnomalibBaseInference

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.