Alexander Suslov commited on
Commit Β·
98f2c2f
1
Parent(s): b134866
added sftpm model fine-tuned on capsule category of the MVTec dataset
Browse files- .gitattributes +1 -0
- README.md +48 -0
- openvino_model.tar +3 -0
- pytorch_model.bin +3 -0
- sftpm_capsule.onnx +3 -0
.gitattributes
CHANGED
|
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
openvino_model.tar filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
---
|
| 4 |
+
[SFTPM](https://github.com/openvinotoolkit/anomalib/tree/main/anomalib/models/stfpm) model from [Anomalib](https://github.com/openvinotoolkit/anomalib) fine-tuned for capsule category of the [MVTec dataset](https://www.mvtec.com/company/research/datasets/mvtec-ad). Checkpoint trained using the following [notebook](https://github.com/openvinotoolkit/anomalib/blob/main/notebooks/000_getting_started/001_getting_started.ipynb).
|
| 5 |
+
|
| 6 |
+
```
|
| 7 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 8 |
+
Test metric DataLoader 0
|
| 9 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
+
image_AUROC 0.8436378240585327
|
| 11 |
+
image_F1Score 0.9356223344802856
|
| 12 |
+
pixel_AUROC 0.9719913601875305
|
| 13 |
+
pixel_F1Score 0.41566985845565796
|
| 14 |
+
ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
The main intent is to use it in samples and demos for model optimization. Here is the advantages:
|
| 18 |
+
- MVTec dataset can automatically downloaded and is quite small.
|
| 19 |
+
- The model from the anomaly detection domain such as SFTPM is sensitive to the optimization methods to allows demonstrate methods with accuracy controll.
|
| 20 |
+
|
| 21 |
+
Here is the code to test the checkpoint:
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
from pytorch_lightning import Trainer
|
| 25 |
+
from anomalib.config import get_configurable_parameters
|
| 26 |
+
from anomalib.data import get_datamodule
|
| 27 |
+
from anomalib.models import get_model
|
| 28 |
+
from anomalib.utils.callbacks import LoadModelCallback, get_callbacks
|
| 29 |
+
|
| 30 |
+
CHECKPOINT_URL = 'https://huggingface.co/alexsu52/sftpm_mvtec_capsule/resolve/main/pytorch_model.bin'
|
| 31 |
+
CHECKPOINT_PATH = '~/pytorch_model.bin'
|
| 32 |
+
|
| 33 |
+
#Download CHECKPOINT_URL to CHECKPOINT_PATH
|
| 34 |
+
|
| 35 |
+
config = get_configurable_parameters(config_path="./anomalib/models/sftpm/config.yaml")
|
| 36 |
+
config["dataset"]["path"] = <path_to_dataset>
|
| 37 |
+
config['dataset']['category'] = 'capsule'
|
| 38 |
+
|
| 39 |
+
datamodule = get_datamodule(config)
|
| 40 |
+
datamodule.setup() # Downloads the dataset if it's not in the specified `root` directory
|
| 41 |
+
datamodule.prepare_data() # Create train/val/test/prediction sets.
|
| 42 |
+
|
| 43 |
+
model = get_model(config)
|
| 44 |
+
|
| 45 |
+
callbacks = get_callbacks(config)
|
| 46 |
+
load_model_callback = LoadModelCallback(weights_path=CHECKPOINT_PATH)
|
| 47 |
+
callbacks.insert(0, load_model_callback)
|
| 48 |
+
|
| 49 |
+
trainer = Trainer(**config.trainer, callbacks=callbacks)
|
| 50 |
+
trainer.test(model=model, datamodule=datamodule)
|
| 51 |
+
```
|
openvino_model.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8420e799269d0b29244fdb32a5b670c3fb63fa8bf56d16547b02774793144b77
|
| 3 |
+
size 44748800
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f3dff45bdddcb077cf2fa5eb7499b3746891f53059aa90bb59da068e62f93c8
|
| 3 |
+
size 33536819
|
sftpm_capsule.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e1dce6ebf6e78428a4d38ff0b78423cbd1e1ec973e1e07954d74fe64435d2428
|
| 3 |
+
size 22522197
|