sinapsis-anomalib 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sinapsis-anomalib might be problematic. Click here for more details.
- sinapsis_anomalib-0.1.0/README.md → sinapsis_anomalib-0.1.1/PKG-INFO +57 -66
- sinapsis_anomalib-0.1.1/README.md +184 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/pyproject.toml +3 -3
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_base.py +1 -1
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_base_inference.py +2 -2
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_export.py +2 -1
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_train.py +2 -1
- sinapsis_anomalib-0.1.1/src/sinapsis_anomalib.egg-info/PKG-INFO +231 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib.egg-info/requires.txt +1 -1
- sinapsis_anomalib-0.1.0/PKG-INFO +0 -949
- sinapsis_anomalib-0.1.0/src/sinapsis_anomalib.egg-info/PKG-INFO +0 -949
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/LICENSE +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/setup.cfg +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/__init__.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/helpers/__init__.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/helpers/config_factory.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/__init__.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_openvino_inference.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_torch_inference.py +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib.egg-info/SOURCES.txt +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib.egg-info/dependency_links.txt +0 -0
- {sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib.egg-info/top_level.txt +0 -0
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sinapsis-anomalib
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Templates for anomaly detection with computer vision using anomalib library.
|
|
5
|
+
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
|
+
Project-URL: Homepage, https://sinapsis.tech
|
|
7
|
+
Project-URL: Documentation, https://docs.sinapsis.tech/docs
|
|
8
|
+
Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
|
|
9
|
+
Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-anomaly-detection.git
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: torch<=2.5.1
|
|
14
|
+
Requires-Dist: einops>=0.8.0
|
|
15
|
+
Requires-Dist: freia>=0.2
|
|
16
|
+
Requires-Dist: imgaug>=0.4.0
|
|
17
|
+
Requires-Dist: kornia>=0.7.4
|
|
18
|
+
Requires-Dist: matplotlib==3.9.0
|
|
19
|
+
Requires-Dist: nncf>=2.14.0
|
|
20
|
+
Requires-Dist: numpy==1.26.4
|
|
21
|
+
Requires-Dist: onnx>=1.17.0
|
|
22
|
+
Requires-Dist: opencv-python>=4.10.0.84
|
|
23
|
+
Requires-Dist: openvino>=2024.5.0
|
|
24
|
+
Requires-Dist: pandas>=2.2.3
|
|
25
|
+
Requires-Dist: psutil>=6.1.0
|
|
26
|
+
Requires-Dist: scikit-learn>=1.5.2
|
|
27
|
+
Requires-Dist: sinapsis>=0.1.1
|
|
28
|
+
Requires-Dist: dotenv>=0.9.9
|
|
29
|
+
Requires-Dist: anomalib>=2.0.0
|
|
30
|
+
Requires-Dist: torchvision>=0.20.1
|
|
31
|
+
Requires-Dist: timm>=1.0.15
|
|
32
|
+
Requires-Dist: open-clip-torch>=2.31.0
|
|
33
|
+
Requires-Dist: lightning>=2.4.1
|
|
34
|
+
Provides-Extra: vlm
|
|
35
|
+
Requires-Dist: python-dotenv>=1.0.1; extra == "vlm"
|
|
36
|
+
Requires-Dist: transformers>=4.45.0; extra == "vlm"
|
|
37
|
+
Requires-Dist: openai>=1.50.0; extra == "vlm"
|
|
38
|
+
Requires-Dist: ollama>=0.4.7; extra == "vlm"
|
|
39
|
+
Provides-Extra: loggers
|
|
40
|
+
Requires-Dist: comet>=3.1.0; extra == "loggers"
|
|
41
|
+
Requires-Dist: mlflow>=2.19.0; extra == "loggers"
|
|
42
|
+
Requires-Dist: tensorboard>=2.18.0; extra == "loggers"
|
|
43
|
+
Requires-Dist: wandb>=0.19.1; extra == "loggers"
|
|
44
|
+
Provides-Extra: all
|
|
45
|
+
Requires-Dist: sinapsis-anomalib[loggers,vlm]; extra == "all"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
1
48
|
<h1 align="center">
|
|
2
49
|
<br>
|
|
3
50
|
<a href="https://sinapsis.tech/">
|
|
@@ -52,75 +99,18 @@ with <code>uv</code>:
|
|
|
52
99
|
<h3> Templates Supported</h3>
|
|
53
100
|
|
|
54
101
|
The **Sinapsis Anomalib** provides a powerful and flexible implementation for anomaly detection with [Anomalib library](https://anomalib.readthedocs.io/en/v1.2.0/).
|
|
55
|
-
<details>
|
|
56
|
-
<summary><strong><span style="font-size: 1.25em;">AnomalibTorchInference</span></strong></summary>
|
|
57
102
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
- **AnomalibTorchInference**\
|
|
104
|
+
_Run anomaly detection inference using PyTorch models._
|
|
105
|
+
- **AnomalibOpenVINOInference**\
|
|
106
|
+
_Perform optimized inference using OpenVINO-accelerated models._
|
|
107
|
+
- **AnomalibTrain**\
|
|
108
|
+
_Train custom anomaly detection models with Anomalib._
|
|
109
|
+
- **AnomalibExport**\
|
|
110
|
+
_Export trained models for deployment in different formats._
|
|
111
|
+
|
|
63
112
|
|
|
64
|
-
<details>
|
|
65
|
-
<summary><strong><span style="font-size: 1.25em;">AnomalibOpenVINOInference</span></strong></summary>
|
|
66
|
-
|
|
67
|
-
The following attributes configure OpenVINO-optimized inference:
|
|
68
|
-
- **`model_path`** (str, required): Path to OpenVINO model directory (containing .xml and .bin).
|
|
69
|
-
- **`transforms`** (dict, optional): Preprocessing steps matching the model's requirements.
|
|
70
|
-
- **`device`** (Literal["CPU", "GPU"], optional): OpenVINO device plugin to use (default: "CPU").
|
|
71
|
-
- **`model_height`** (int, required): The image height expected by OV model.
|
|
72
|
-
- **`model_width`** (int, required): The image width expected by OV model.
|
|
73
|
-
</details>
|
|
74
|
-
<details>
|
|
75
|
-
<summary><strong><span style="font-size: 1.25em;">AnomalibTrain</span></strong></summary>
|
|
76
|
-
|
|
77
|
-
The following attributes apply to AnomalibTrain template:
|
|
78
|
-
- **`folder_attributes_config_path`** (str | Path, required): Path to datamodule configuration YAML file. This must follow Anomalib's [Folder data format specification](https://anomalib.readthedocs.io/en/v1.2.0/markdown/guides/reference/data/image/folder.html). An example configuration is provided at `packages/sinapsis_anomalib/src/sinapsis_anomalib/configs/datamodule_config.yml`.
|
|
79
|
-
- **`generic_key`** (str, required): Unique identifier for training artifacts.
|
|
80
|
-
- **`callbacks`** (list[Callback], optional): PyTorch Lightning callbacks.
|
|
81
|
-
- **`normalization`** (dict, optional): Input normalization configuration.
|
|
82
|
-
- **`threshold`** (dict, optional): Anomaly threshold settings.
|
|
83
|
-
- **`task`** (TaskType, optional): Task type (classification/detection/segmentation).
|
|
84
|
-
- **`image_metrics`** (list, optional): Image-level evaluation metrics.
|
|
85
|
-
- **`pixel_metrics`** (list, optional): Pixel-level evaluation metrics.
|
|
86
|
-
- **`logger`** (Logger, optional): Training logger configuration.
|
|
87
|
-
- **`default_root_dir`** (Path, required): Output directory for training artifacts.
|
|
88
|
-
- **`callback_configs`** (dict, optional): Callback initialization parameters.
|
|
89
|
-
- **`logger_configs`** (dict, optional): Logger initialization parameters.
|
|
90
|
-
- **`max_epochs`** (int, optional): Maximum training epochs.
|
|
91
|
-
- **`ckpt_path`** (str | Path, optional): Checkpoint path for resuming training.
|
|
92
|
-
- **`accelerator`** (Literal["cpu", "gpu", "tpu", "hpu", "auto"]): Define the device to be used during training. Defaults to "cpu".
|
|
93
|
-
- **`trainer_args`** (dict[str, Any]): General trainer asrguments. For more details see:
|
|
94
|
-
https://lightning.ai/docs/pytorch/stable/common/trainer.html#trainer-flags
|
|
95
|
-
|
|
96
|
-
Additional model-specific attributes can be dynamically assigned through the class initialization dictionary (`*_init` attributes). These attributes correspond directly to the arguments used in Anomalib Models. Typically used for hyperparameters directly assigned to the corresponding model or to modify the model's architecture.
|
|
97
|
-
</details>
|
|
98
113
|
|
|
99
|
-
<details>
|
|
100
|
-
<summary><strong><span style="font-size: 1.25em;">AnomalibExport</span></strong></summary>
|
|
101
|
-
|
|
102
|
-
The following attributes apply to AnomalibExport template:
|
|
103
|
-
- **`folder_attributes_config_path`** (str | Path, required for INT8_ACQ/INT8_PTQ compression): Path to datamodule configuration YAML (only required when using INT8 quantization). Must follow Anomalib's [Folder data format](https://anomalib.readthedocs.io/en/v1.2.0/markdown/guides/reference/data/image/folder.html).
|
|
104
|
-
- **`callbacks`** (list[Callback], optional): PyTorch Lightning callbacks.
|
|
105
|
-
- **`normalization`** (dict, optional): Input normalization configuration.
|
|
106
|
-
- **`threshold`** (dict, optional): Anomaly threshold settings.
|
|
107
|
-
- **`image_metrics`** (list, optional): Image-level evaluation metrics.
|
|
108
|
-
- **`pixel_metrics`** (list, optional): Pixel-level evaluation metrics.
|
|
109
|
-
- **`logger`** (Logger, optional): Training logger configuration.
|
|
110
|
-
- **`default_root_dir`** (Path, required): Output directory for training artifacts.
|
|
111
|
-
- **`callback_configs`** (dict, optional): Callback initialization parameters.
|
|
112
|
-
- **`logger_configs`** (dict, optional): Logger initialization parameters.
|
|
113
|
-
- **`export_type`** (ExportType | str, required): Export format (TORCH/ONNX/OPENVINO).
|
|
114
|
-
- **`export_root`** (str | Path, optional): Output directory for exported models.
|
|
115
|
-
- **`input_size`** (tuple[int, int], optional): Model input dimensions.
|
|
116
|
-
- **`compression_type`** (CompressionType, optional): Model compression method.
|
|
117
|
-
- **`metric`** (Metric | str, optional): Calibration metric.
|
|
118
|
-
- **`ov_args`** (dict, optional): OpenVINO-specific arguments.
|
|
119
|
-
- **`ckpt_path`** (str, optional): Explicit checkpoint path override.
|
|
120
|
-
- **`generic_key_chkpt`** (str, optional): Alternate key for checkpoint loading.
|
|
121
|
-
|
|
122
|
-
Additional model-specific attributes can be dynamically assigned through the class initialization dictionary (`*_init` attributes). These attributes correspond directly to the arguments used in Anomalib Models. Typically used for hyperparameters directly assigned to the corresponding model or to modify the model's architecture.
|
|
123
|
-
</details>
|
|
124
114
|
|
|
125
115
|
> [!TIP]
|
|
126
116
|
> Use CLI command ``` sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis Anomalib.
|
|
@@ -211,6 +201,7 @@ templates:
|
|
|
211
201
|
export_root: "results/model/exported"
|
|
212
202
|
```
|
|
213
203
|
</details>
|
|
204
|
+
|
|
214
205
|
This configuration defines an **agent** and a sequence of **templates** to train and export a model based on a certain data configuration.
|
|
215
206
|
|
|
216
207
|
> [!IMPORTANT]
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
<a href="https://sinapsis.tech/">
|
|
4
|
+
<img
|
|
5
|
+
src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
|
|
6
|
+
alt="" width="300">
|
|
7
|
+
</a><br>
|
|
8
|
+
Sinapsis Anomalib
|
|
9
|
+
<br>
|
|
10
|
+
</h1>
|
|
11
|
+
|
|
12
|
+
<h4 align="center">Module to provide anomaly detection training, inference and export with Anomalib.</h4>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="#installation">🐍 Installation</a> •
|
|
16
|
+
<a href="#features"> 🚀 Features</a> •
|
|
17
|
+
<a href="#example"> 📚 Usage Example</a> •
|
|
18
|
+
<a href="#documentation">📙 Documentation</a> •
|
|
19
|
+
<a href="#license"> 🔍 License </a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<h2 id="installation"> 🐍 Installation </h2>
|
|
23
|
+
|
|
24
|
+
Install using your package manager of choice. We encourage the use of <code>uv</code>
|
|
25
|
+
|
|
26
|
+
Example with <code>uv</code>:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech
|
|
30
|
+
```
|
|
31
|
+
or with raw <code>pip</code>:
|
|
32
|
+
```bash
|
|
33
|
+
pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> [!IMPORTANT]
|
|
37
|
+
> Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:
|
|
38
|
+
>
|
|
39
|
+
|
|
40
|
+
with <code>uv</code>:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech
|
|
44
|
+
```
|
|
45
|
+
or with raw <code>pip</code>:
|
|
46
|
+
```bash
|
|
47
|
+
pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<h2 id="features">🚀 Features</h2>
|
|
51
|
+
|
|
52
|
+
<h3> Templates Supported</h3>
|
|
53
|
+
|
|
54
|
+
The **Sinapsis Anomalib** provides a powerful and flexible implementation for anomaly detection with [Anomalib library](https://anomalib.readthedocs.io/en/v1.2.0/).
|
|
55
|
+
|
|
56
|
+
- **AnomalibTorchInference**\
|
|
57
|
+
_Run anomaly detection inference using PyTorch models._
|
|
58
|
+
- **AnomalibOpenVINOInference**\
|
|
59
|
+
_Perform optimized inference using OpenVINO-accelerated models._
|
|
60
|
+
- **AnomalibTrain**\
|
|
61
|
+
_Train custom anomaly detection models with Anomalib._
|
|
62
|
+
- **AnomalibExport**\
|
|
63
|
+
_Export trained models for deployment in different formats._
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
> [!TIP]
|
|
69
|
+
> Use CLI command ``` sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis Anomalib.
|
|
70
|
+
|
|
71
|
+
> [!TIP]
|
|
72
|
+
> Use CLI command ```sinapsis info --example-template-config TEMPLATE_NAME``` to produce an example Agent config for the Template specified in ***TEMPLATE_NAME***.
|
|
73
|
+
|
|
74
|
+
For example, for ***CfaTrain*** use ```sinapsis info --example-template-config CfaTrain``` to produce the following example config:
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
agent:
|
|
78
|
+
name: my_test_agent
|
|
79
|
+
templates:
|
|
80
|
+
- template_name: InputTemplate
|
|
81
|
+
class_name: InputTemplate
|
|
82
|
+
attributes: {}
|
|
83
|
+
- template_name: CfaTrain
|
|
84
|
+
class_name: CfaTrain
|
|
85
|
+
template_input: InputTemplate
|
|
86
|
+
attributes:
|
|
87
|
+
folder_attributes_config_path: null
|
|
88
|
+
generic_key: 'my_generic_key'
|
|
89
|
+
callbacks: null
|
|
90
|
+
normalization: null
|
|
91
|
+
threshold: null
|
|
92
|
+
image_metrics: null
|
|
93
|
+
pixel_metrics: null
|
|
94
|
+
logger: null
|
|
95
|
+
default_root_dir: null
|
|
96
|
+
callback_configs: null
|
|
97
|
+
logger_configs: null
|
|
98
|
+
max_epochs: null
|
|
99
|
+
ckpt_path: null
|
|
100
|
+
cfa_init:
|
|
101
|
+
backbone: wide_resnet50_2
|
|
102
|
+
gamma_c: 1
|
|
103
|
+
gamma_d: 1
|
|
104
|
+
num_nearest_neighbors: 3
|
|
105
|
+
num_hard_negative_features: 3
|
|
106
|
+
radius: 1.0e-05
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
<details>
|
|
110
|
+
<summary><strong><span style="font-size: 1.25em;">🚫 Excluded Models</span></strong></summary>
|
|
111
|
+
|
|
112
|
+
Some models that required additional configuration have been excluded and support for this will be included in future releases.
|
|
113
|
+
|
|
114
|
+
- **EfficientAd**
|
|
115
|
+
- **VlmAd**
|
|
116
|
+
- **Cfa**
|
|
117
|
+
- **Dfkde**
|
|
118
|
+
- **Fastflow**
|
|
119
|
+
- **Supersimplenet**
|
|
120
|
+
- **AiVad**
|
|
121
|
+
|
|
122
|
+
For all other supported models, refer to the Anomalib documentation linked above.
|
|
123
|
+
</details>
|
|
124
|
+
|
|
125
|
+
<h2 id="example"> 📚 Usage Example </h2>
|
|
126
|
+
Below is an example configuration for **Sinapsis Anomalib** using a CFLOW model. This setup trains an anomaly detection model with configurable hyperparameters, including learning rate and epochs, and exports it in OpenVINO format for optimized inference. The pipeline includes training, model export, and predefined paths for outputs.
|
|
127
|
+
|
|
128
|
+
<details>
|
|
129
|
+
<summary><strong><span style="font-size: 1.25em;">Example config</span></strong></summary>
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
agent:
|
|
133
|
+
name: anomalib_train_export
|
|
134
|
+
|
|
135
|
+
templates:
|
|
136
|
+
- template_name: InputTemplate
|
|
137
|
+
class_name: InputTemplate
|
|
138
|
+
attributes: {}
|
|
139
|
+
|
|
140
|
+
- template_name: CflowTrain
|
|
141
|
+
class_name: CflowTrain
|
|
142
|
+
attributes:
|
|
143
|
+
folder_attributes_config_path: "configs/datamodule_config.yml"
|
|
144
|
+
default_root_dir: "results/model"
|
|
145
|
+
max_epochs: 1
|
|
146
|
+
cflow_init:
|
|
147
|
+
lr: 0.0001
|
|
148
|
+
|
|
149
|
+
- template_name: CflowExport
|
|
150
|
+
class_name: CflowExport
|
|
151
|
+
attributes:
|
|
152
|
+
generic_key_chkpt: "CflowTrain"
|
|
153
|
+
export_type: "openvino"
|
|
154
|
+
export_root: "results/model/exported"
|
|
155
|
+
```
|
|
156
|
+
</details>
|
|
157
|
+
|
|
158
|
+
This configuration defines an **agent** and a sequence of **templates** to train and export a model based on a certain data configuration.
|
|
159
|
+
|
|
160
|
+
> [!IMPORTANT]
|
|
161
|
+
>Attributes specified under the `*_init` keys (e.g., `cflow_init`) correspond directly to the Anomalib models parameters. Ensure that values are assigned correctly according to the official [Anomalib documentation](https://anomalib.readthedocs.io/en/v1.2.0/), as they affect the behavior and performance of the model.
|
|
162
|
+
>
|
|
163
|
+
|
|
164
|
+
To run the config, use the CLI:
|
|
165
|
+
```bash
|
|
166
|
+
sinapsis run name_of_config.yml
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
</details>
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
<h2 id="documentation">📙 Documentation</h2>
|
|
174
|
+
|
|
175
|
+
Documentation for this and other sinapsis packages is available on the [sinapsis website](https://docs.sinapsis.tech/docs)
|
|
176
|
+
|
|
177
|
+
Tutorials for different projects within sinapsis are available at [sinapsis tutorials page](https://docs.sinapsis.tech/tutorials)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
<h2 id="license">🔍 License</h2>
|
|
181
|
+
|
|
182
|
+
This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.
|
|
183
|
+
|
|
184
|
+
For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sinapsis-anomalib"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.1"
|
|
4
4
|
description = "Templates for anomaly detection with computer vision using anomalib library."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "SinapsisAI", email = "dev@sinapsis.tech"},
|
|
7
7
|
]
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
license =
|
|
9
|
+
license-files = ["LICENSE"]
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
|
|
12
12
|
dependencies = [
|
|
@@ -15,7 +15,6 @@ dependencies = [
|
|
|
15
15
|
"freia>=0.2",
|
|
16
16
|
"imgaug>=0.4.0",
|
|
17
17
|
"kornia>=0.7.4",
|
|
18
|
-
"lightning>=2.4.0",
|
|
19
18
|
"matplotlib==3.9.0",
|
|
20
19
|
"nncf>=2.14.0",
|
|
21
20
|
"numpy==1.26.4",
|
|
@@ -31,6 +30,7 @@ dependencies = [
|
|
|
31
30
|
"torchvision>=0.20.1",
|
|
32
31
|
"timm>=1.0.15",
|
|
33
32
|
"open-clip-torch>=2.31.0",
|
|
33
|
+
"lightning>=2.4.1",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.optional-dependencies]
|
{sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib/templates/anomalib_base.py
RENAMED
|
@@ -13,7 +13,7 @@ from lightning.pytorch.loggers import Logger
|
|
|
13
13
|
from pydantic import BaseModel, ConfigDict
|
|
14
14
|
from pydantic.dataclasses import dataclass
|
|
15
15
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
16
|
-
from sinapsis_core.template_base import TemplateAttributes, TemplateAttributeType
|
|
16
|
+
from sinapsis_core.template_base.base_models import TemplateAttributes, TemplateAttributeType
|
|
17
17
|
from sinapsis_core.template_base.dynamic_template import BaseDynamicWrapperTemplate, WrapperEntryConfig
|
|
18
18
|
|
|
19
19
|
from sinapsis_anomalib.helpers.config_factory import CallbackFactory, LoggerFactory
|
|
@@ -15,8 +15,8 @@ from sinapsis_core.data_containers.annotations import (
|
|
|
15
15
|
Segmentation,
|
|
16
16
|
)
|
|
17
17
|
from sinapsis_core.data_containers.data_packet import DataContainer, ImagePacket
|
|
18
|
-
from sinapsis_core.template_base import
|
|
19
|
-
|
|
18
|
+
from sinapsis_core.template_base import Template
|
|
19
|
+
from sinapsis_core.template_base.base_models import (
|
|
20
20
|
TemplateAttributes,
|
|
21
21
|
TemplateAttributeType,
|
|
22
22
|
)
|
|
@@ -5,7 +5,8 @@ from typing import Any
|
|
|
5
5
|
from anomalib.deploy import CompressionType, ExportType
|
|
6
6
|
from pydantic.dataclasses import dataclass
|
|
7
7
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
8
|
-
from sinapsis_core.template_base import Template
|
|
8
|
+
from sinapsis_core.template_base import Template
|
|
9
|
+
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
9
10
|
from sinapsis_core.template_base.dynamic_template_factory import make_dynamic_template
|
|
10
11
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_BUILD_DOCS
|
|
11
12
|
from torchmetrics import Metric
|
|
@@ -6,7 +6,8 @@ from anomalib.engine.engine import _TrainerArgumentsCache
|
|
|
6
6
|
from pydantic import Field
|
|
7
7
|
from pydantic.dataclasses import dataclass
|
|
8
8
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
9
|
-
from sinapsis_core.template_base import Template
|
|
9
|
+
from sinapsis_core.template_base import Template
|
|
10
|
+
from sinapsis_core.template_base.base_models import TemplateAttributeType
|
|
10
11
|
from sinapsis_core.template_base.dynamic_template_factory import make_dynamic_template
|
|
11
12
|
from sinapsis_core.utils.env_var_keys import SINAPSIS_BUILD_DOCS
|
|
12
13
|
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sinapsis-anomalib
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Templates for anomaly detection with computer vision using anomalib library.
|
|
5
|
+
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
|
+
Project-URL: Homepage, https://sinapsis.tech
|
|
7
|
+
Project-URL: Documentation, https://docs.sinapsis.tech/docs
|
|
8
|
+
Project-URL: Tutorials, https://docs.sinapsis.tech/tutorials
|
|
9
|
+
Project-URL: Repository, https://github.com/Sinapsis-AI/sinapsis-anomaly-detection.git
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: torch<=2.5.1
|
|
14
|
+
Requires-Dist: einops>=0.8.0
|
|
15
|
+
Requires-Dist: freia>=0.2
|
|
16
|
+
Requires-Dist: imgaug>=0.4.0
|
|
17
|
+
Requires-Dist: kornia>=0.7.4
|
|
18
|
+
Requires-Dist: matplotlib==3.9.0
|
|
19
|
+
Requires-Dist: nncf>=2.14.0
|
|
20
|
+
Requires-Dist: numpy==1.26.4
|
|
21
|
+
Requires-Dist: onnx>=1.17.0
|
|
22
|
+
Requires-Dist: opencv-python>=4.10.0.84
|
|
23
|
+
Requires-Dist: openvino>=2024.5.0
|
|
24
|
+
Requires-Dist: pandas>=2.2.3
|
|
25
|
+
Requires-Dist: psutil>=6.1.0
|
|
26
|
+
Requires-Dist: scikit-learn>=1.5.2
|
|
27
|
+
Requires-Dist: sinapsis>=0.1.1
|
|
28
|
+
Requires-Dist: dotenv>=0.9.9
|
|
29
|
+
Requires-Dist: anomalib>=2.0.0
|
|
30
|
+
Requires-Dist: torchvision>=0.20.1
|
|
31
|
+
Requires-Dist: timm>=1.0.15
|
|
32
|
+
Requires-Dist: open-clip-torch>=2.31.0
|
|
33
|
+
Requires-Dist: lightning>=2.4.1
|
|
34
|
+
Provides-Extra: vlm
|
|
35
|
+
Requires-Dist: python-dotenv>=1.0.1; extra == "vlm"
|
|
36
|
+
Requires-Dist: transformers>=4.45.0; extra == "vlm"
|
|
37
|
+
Requires-Dist: openai>=1.50.0; extra == "vlm"
|
|
38
|
+
Requires-Dist: ollama>=0.4.7; extra == "vlm"
|
|
39
|
+
Provides-Extra: loggers
|
|
40
|
+
Requires-Dist: comet>=3.1.0; extra == "loggers"
|
|
41
|
+
Requires-Dist: mlflow>=2.19.0; extra == "loggers"
|
|
42
|
+
Requires-Dist: tensorboard>=2.18.0; extra == "loggers"
|
|
43
|
+
Requires-Dist: wandb>=0.19.1; extra == "loggers"
|
|
44
|
+
Provides-Extra: all
|
|
45
|
+
Requires-Dist: sinapsis-anomalib[loggers,vlm]; extra == "all"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
<h1 align="center">
|
|
49
|
+
<br>
|
|
50
|
+
<a href="https://sinapsis.tech/">
|
|
51
|
+
<img
|
|
52
|
+
src="https://github.com/Sinapsis-AI/brand-resources/blob/main/sinapsis_logo/4x/logo.png?raw=true"
|
|
53
|
+
alt="" width="300">
|
|
54
|
+
</a><br>
|
|
55
|
+
Sinapsis Anomalib
|
|
56
|
+
<br>
|
|
57
|
+
</h1>
|
|
58
|
+
|
|
59
|
+
<h4 align="center">Module to provide anomaly detection training, inference and export with Anomalib.</h4>
|
|
60
|
+
|
|
61
|
+
<p align="center">
|
|
62
|
+
<a href="#installation">🐍 Installation</a> •
|
|
63
|
+
<a href="#features"> 🚀 Features</a> •
|
|
64
|
+
<a href="#example"> 📚 Usage Example</a> •
|
|
65
|
+
<a href="#documentation">📙 Documentation</a> •
|
|
66
|
+
<a href="#license"> 🔍 License </a>
|
|
67
|
+
</p>
|
|
68
|
+
|
|
69
|
+
<h2 id="installation"> 🐍 Installation </h2>
|
|
70
|
+
|
|
71
|
+
Install using your package manager of choice. We encourage the use of <code>uv</code>
|
|
72
|
+
|
|
73
|
+
Example with <code>uv</code>:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech
|
|
77
|
+
```
|
|
78
|
+
or with raw <code>pip</code>:
|
|
79
|
+
```bash
|
|
80
|
+
pip install sinapsis-anomalib --extra-index-url https://pypi.sinapsis.tech
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
> [!IMPORTANT]
|
|
84
|
+
> Templates in each package may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:
|
|
85
|
+
>
|
|
86
|
+
|
|
87
|
+
with <code>uv</code>:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
uv pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech
|
|
91
|
+
```
|
|
92
|
+
or with raw <code>pip</code>:
|
|
93
|
+
```bash
|
|
94
|
+
pip install sinapsis-anomalib[all] --extra-index-url https://pypi.sinapsis.tech
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
<h2 id="features">🚀 Features</h2>
|
|
98
|
+
|
|
99
|
+
<h3> Templates Supported</h3>
|
|
100
|
+
|
|
101
|
+
The **Sinapsis Anomalib** provides a powerful and flexible implementation for anomaly detection with [Anomalib library](https://anomalib.readthedocs.io/en/v1.2.0/).
|
|
102
|
+
|
|
103
|
+
- **AnomalibTorchInference**\
|
|
104
|
+
_Run anomaly detection inference using PyTorch models._
|
|
105
|
+
- **AnomalibOpenVINOInference**\
|
|
106
|
+
_Perform optimized inference using OpenVINO-accelerated models._
|
|
107
|
+
- **AnomalibTrain**\
|
|
108
|
+
_Train custom anomaly detection models with Anomalib._
|
|
109
|
+
- **AnomalibExport**\
|
|
110
|
+
_Export trained models for deployment in different formats._
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
> [!TIP]
|
|
116
|
+
> Use CLI command ``` sinapsis info --all-template-names``` to show a list with all the available Template names installed with Sinapsis Anomalib.
|
|
117
|
+
|
|
118
|
+
> [!TIP]
|
|
119
|
+
> Use CLI command ```sinapsis info --example-template-config TEMPLATE_NAME``` to produce an example Agent config for the Template specified in ***TEMPLATE_NAME***.
|
|
120
|
+
|
|
121
|
+
For example, for ***CfaTrain*** use ```sinapsis info --example-template-config CfaTrain``` to produce the following example config:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
agent:
|
|
125
|
+
name: my_test_agent
|
|
126
|
+
templates:
|
|
127
|
+
- template_name: InputTemplate
|
|
128
|
+
class_name: InputTemplate
|
|
129
|
+
attributes: {}
|
|
130
|
+
- template_name: CfaTrain
|
|
131
|
+
class_name: CfaTrain
|
|
132
|
+
template_input: InputTemplate
|
|
133
|
+
attributes:
|
|
134
|
+
folder_attributes_config_path: null
|
|
135
|
+
generic_key: 'my_generic_key'
|
|
136
|
+
callbacks: null
|
|
137
|
+
normalization: null
|
|
138
|
+
threshold: null
|
|
139
|
+
image_metrics: null
|
|
140
|
+
pixel_metrics: null
|
|
141
|
+
logger: null
|
|
142
|
+
default_root_dir: null
|
|
143
|
+
callback_configs: null
|
|
144
|
+
logger_configs: null
|
|
145
|
+
max_epochs: null
|
|
146
|
+
ckpt_path: null
|
|
147
|
+
cfa_init:
|
|
148
|
+
backbone: wide_resnet50_2
|
|
149
|
+
gamma_c: 1
|
|
150
|
+
gamma_d: 1
|
|
151
|
+
num_nearest_neighbors: 3
|
|
152
|
+
num_hard_negative_features: 3
|
|
153
|
+
radius: 1.0e-05
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
<details>
|
|
157
|
+
<summary><strong><span style="font-size: 1.25em;">🚫 Excluded Models</span></strong></summary>
|
|
158
|
+
|
|
159
|
+
Some models that required additional configuration have been excluded and support for this will be included in future releases.
|
|
160
|
+
|
|
161
|
+
- **EfficientAd**
|
|
162
|
+
- **VlmAd**
|
|
163
|
+
- **Cfa**
|
|
164
|
+
- **Dfkde**
|
|
165
|
+
- **Fastflow**
|
|
166
|
+
- **Supersimplenet**
|
|
167
|
+
- **AiVad**
|
|
168
|
+
|
|
169
|
+
For all other supported models, refer to the Anomalib documentation linked above.
|
|
170
|
+
</details>
|
|
171
|
+
|
|
172
|
+
<h2 id="example"> 📚 Usage Example </h2>
|
|
173
|
+
Below is an example configuration for **Sinapsis Anomalib** using a CFLOW model. This setup trains an anomaly detection model with configurable hyperparameters, including learning rate and epochs, and exports it in OpenVINO format for optimized inference. The pipeline includes training, model export, and predefined paths for outputs.
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary><strong><span style="font-size: 1.25em;">Example config</span></strong></summary>
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
agent:
|
|
180
|
+
name: anomalib_train_export
|
|
181
|
+
|
|
182
|
+
templates:
|
|
183
|
+
- template_name: InputTemplate
|
|
184
|
+
class_name: InputTemplate
|
|
185
|
+
attributes: {}
|
|
186
|
+
|
|
187
|
+
- template_name: CflowTrain
|
|
188
|
+
class_name: CflowTrain
|
|
189
|
+
attributes:
|
|
190
|
+
folder_attributes_config_path: "configs/datamodule_config.yml"
|
|
191
|
+
default_root_dir: "results/model"
|
|
192
|
+
max_epochs: 1
|
|
193
|
+
cflow_init:
|
|
194
|
+
lr: 0.0001
|
|
195
|
+
|
|
196
|
+
- template_name: CflowExport
|
|
197
|
+
class_name: CflowExport
|
|
198
|
+
attributes:
|
|
199
|
+
generic_key_chkpt: "CflowTrain"
|
|
200
|
+
export_type: "openvino"
|
|
201
|
+
export_root: "results/model/exported"
|
|
202
|
+
```
|
|
203
|
+
</details>
|
|
204
|
+
|
|
205
|
+
This configuration defines an **agent** and a sequence of **templates** to train and export a model based on a certain data configuration.
|
|
206
|
+
|
|
207
|
+
> [!IMPORTANT]
|
|
208
|
+
>Attributes specified under the `*_init` keys (e.g., `cflow_init`) correspond directly to the Anomalib models parameters. Ensure that values are assigned correctly according to the official [Anomalib documentation](https://anomalib.readthedocs.io/en/v1.2.0/), as they affect the behavior and performance of the model.
|
|
209
|
+
>
|
|
210
|
+
|
|
211
|
+
To run the config, use the CLI:
|
|
212
|
+
```bash
|
|
213
|
+
sinapsis run name_of_config.yml
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
</details>
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
<h2 id="documentation">📙 Documentation</h2>
|
|
221
|
+
|
|
222
|
+
Documentation for this and other sinapsis packages is available on the [sinapsis website](https://docs.sinapsis.tech/docs)
|
|
223
|
+
|
|
224
|
+
Tutorials for different projects within sinapsis are available at [sinapsis tutorials page](https://docs.sinapsis.tech/tutorials)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
<h2 id="license">🔍 License</h2>
|
|
228
|
+
|
|
229
|
+
This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the [LICENSE](LICENSE) file.
|
|
230
|
+
|
|
231
|
+
For commercial use, please refer to our [official Sinapsis website](https://sinapsis.tech) for information on obtaining a commercial license.
|
{sinapsis_anomalib-0.1.0 → sinapsis_anomalib-0.1.1}/src/sinapsis_anomalib.egg-info/requires.txt
RENAMED
|
@@ -3,7 +3,6 @@ einops>=0.8.0
|
|
|
3
3
|
freia>=0.2
|
|
4
4
|
imgaug>=0.4.0
|
|
5
5
|
kornia>=0.7.4
|
|
6
|
-
lightning>=2.4.0
|
|
7
6
|
matplotlib==3.9.0
|
|
8
7
|
nncf>=2.14.0
|
|
9
8
|
numpy==1.26.4
|
|
@@ -19,6 +18,7 @@ anomalib>=2.0.0
|
|
|
19
18
|
torchvision>=0.20.1
|
|
20
19
|
timm>=1.0.15
|
|
21
20
|
open-clip-torch>=2.31.0
|
|
21
|
+
lightning>=2.4.1
|
|
22
22
|
|
|
23
23
|
[all]
|
|
24
24
|
sinapsis-anomalib[loggers,vlm]
|