GeneralADExport
Python template · sinapsis_anomalib.templates.anomalib_export
Overview
Export functionality for trained Anomalib models.
GeneralAD — inherited documentation
GeneralAD Lightning module.
Args: backbone: Timm backbone used as frozen feature extractor. layers: Backbone stages or transformer blocks used for patch features. hidden_dim: Hidden size of the patch discriminator. lr: Optimizer learning rate. lr_decay_factor: Final cosine annealing ratio. weight_decay: Optimizer weight decay. epochs: Number of epochs used to parameterize the LR scheduler. noise_std: Standard deviation for synthetic anomalous features. dsc_layers: Number of attention blocks in the discriminator. dsc_heads: Number of attention heads in the discriminator. dsc_dropout: Dropout rate in the discriminator. num_fake_patches: Maximum number of perturbed patches per image. fake_feature_type: Strategy for generating pseudo anomalies. top_k: Number of highest patch scores to average for image scoring. pre_trained: Whether to use pretrained backbone weights. pre_processor: Optional anomalib pre-processor. post_processor: Optional anomalib post-processor. evaluator: Optional anomalib evaluator. visualizer: Optional anomalib visualizer.
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-anomalib==1.0.0uv pip install sinapsis-anomalib==1.0.0uv add sinapsis-anomalib==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Metric used for compression calibration.
Optional
Default: null
OpenVINO-specific export arguments.
Optional
Default: null
Optional
Default: false
If True, compresses the model weights to FP16 precision. Defaults to None. Print detailed information about conversion.
Optional
Default: null
Optional
Default: null
Optional
Default: null
Explicit path to model checkpoint.
Optional
Default: null
Optional
Default: null
Expected input dimensions (height, width).
Optional
Default: null
Root directory for exported files.
Optional
Default: null
Target export format. Defaults to TORCH.
Optional
Default: "torch"
Optional
Default: null
Optional
Default: null
Optional
Default: null
Required
Default: null
Optional
Default: 0.0005
Optional
Default: 10
Optional
Default: 160
Optional
Default: [24]
Optional
Default: "vit_large_patch14_dinov2.lvd142m"
Optional
Default: 4
Optional
Default: true
Optional
Default: 0.25
Optional
Default: 1
Optional
Default: 2048
Optional
Default: true
Optional
Default: 0.1
Optional
Default: true
Optional
Default: 0.00001
Optional
Default: true
Optional
Default: true
Optional
Default: 0.2
Optional
Default: -1
Optional
Default: "random"
Optional
Default: null
Optional
Default: null
Quantization/compression method.
Optional
Default: null
Optional
Default: null
A descriptive name for the dataset.
Required
Default: null
The root directory where the dataset is located.
Optional
Default: null
A random seed for reproducibility in data splitting.
Optional
Default: null
Optional
Default: null
Optional
Default: null
Path to the directory containing normal images.
Required
Default: null
The number of subprocesses to use for data loading. Defaults to 8.
Optional
Default: 8
Path to the directory for abnormal images.
Optional
Default: null
Optional
Default: "from_test"
The number of samples per batch for evaluation. Defaults to 32.
Optional
Default: 32
Optional
Default: null
Optional
Default: "from_dir"
Optional
Default: 0.5
Optional
Default: 0.2
The number of samples per batch for training. Defaults to 32.
Optional
Default: 32
Optional
Default: 0.2
Key to retrieve training results. generalad_init backbone <class 'str'>: default: vit_large_patch14_dinov2.lvd142m layers typing.Sequence[int]: default: (24,) hidden_dim <class 'int'>: default: 2048 lr <class 'float'>:… Read full field description
Key to retrieve training results. generalad_init backbone <class 'str'>: default: vit_large_patch14_dinov2.lvd142m layers typing.Sequence[int]: default: (24,) hidden_dim <class 'int'>: default: 2048 lr <class 'float'>: default: 0.0005 lr_decay_factor <class 'float'>: default: 0.2 weight_decay <class 'float'>: default: 1e-05 epochs <class 'int'>: default: 160 noise_std <class 'float'>: default: 0.25 dsc_layers <class 'int'>: default: 1 dsc_heads <class 'int'>: default: 4 dsc_dropout <class 'float'>: default: 0.1 num_fake_patches <class 'int'>: default: -1 fake_feature_type typing.Any: default: random top_k <class 'int'>: default: 10 pre_trained <class 'bool'>: default: True pre_processor typing.Any: default: True post_processor typing.Any: default: True evaluator typing.Any: default: True visualizer typing.Any: default: True
Optional
Default: null
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "GeneralADExport"
class_name: "GeneralADExport"
attributes:
logger: null
metric: null
ov_args:
verbose: false
compress_to_fp16: null
callbacks: null
ckpt_path: null
threshold: null
input_size: null
export_root: null
export_type: {}
image_metrics: null
normalization: null
pixel_metrics: null
generalad_init:
lr: 0.0005
top_k: 10
epochs: 160
layers: [24]
backbone: "vit_large_patch14_dinov2.lvd142m"
dsc_heads: 4
evaluator: true
noise_std: 0.25
dsc_layers: 1
hidden_dim: 2048
visualizer: true
dsc_dropout: 0.1
pre_trained: true
weight_decay: 0.00001
pre_processor: true
post_processor: true
lr_decay_factor: 0.2
num_fake_patches: -1
fake_feature_type: "random"
logger_configs: null
callback_configs: null
compression_type: null
folder_attributes:
name: "<required>"
root: null
seed: null
mask_dir: null
extensions: null
normal_dir: "<required>"
num_workers: 8
abnormal_dir: null
val_split_mode: "from_test"
eval_batch_size: 32
normal_test_dir: null
test_split_mode: "from_dir"
val_split_ratio: 0.5
test_split_ratio: 0.2
train_batch_size: 32
normal_split_ratio: 0.2
generic_key_chkpt: null
View original docstring example
The source example references CfaExport, not GeneralADExport.
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: CfaExport
class_name: CfaExport
template_input: InputTemplate
attributes:
folder_attributes_config_path: null
generic_key: 'my_generic_key'
callbacks: null
normalization: null
threshold: null
task: null
image_metrics: null
pixel_metrics: null
logger: null
callback_configs: null
logger_configs: null
export_type: 'openvino'
export_root: null
input_size: null
transform: null
compression_type: null
metric: null
ov_args: null
ckpt_path: null
generic_key_chkpt: null
cfa_init:
backbone: wide_resnet50_2
gamma_c: 1
gamma_d: 1
num_nearest_neighbors: 3
num_hard_negative_features: 3
radius: 1.0e-05
For a full list of options use the sinapsis cli: sinapsis info --all-template-names
If you want to see all available models, please visit:
https://anomalib.readthedocs.io/en/v1.2.0/markdown/guides/reference/models/image/index.html
Notes:
- Supports multiple export formats via ExportType
- Enables model compression through CompressionType.
- Can load models from checkpoints or previous training results.Inheritance
sinapsis_anomalib.templates.anomalib_export.AnomalibExportEnvironment variables
Environment definitions belong to their canonical Python modules.