Fushi21 commited on
Commit
37b8db7
·
verified ·
1 Parent(s): 2e61be3

Model card

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: onnx
4
+ pipeline_tag: image-classification
5
+ tags:
6
+ - anomaly-detection
7
+ - visual-inspection
8
+ - patchcore
9
+ - winclip
10
+ - onnx
11
+ ---
12
+
13
+ # Vision QC models
14
+
15
+ ONNX models used by [Vision QC](https://github.com/pdlong4002/vision-qc), a visual defect inspection app that learns
16
+ from good photos only and runs on a CPU. Download them with the app's `scripts/download_models.py` (checks the
17
+ SHA-256 below), or place them by hand under the app's `models/` folder with the same paths.
18
+
19
+ | File | Size | Used for |
20
+ |---|---|---|
21
+ | `backbone/wide_resnet50_l23.onnx` | 99 MB | PatchCore feature extractor (required) |
22
+ | `zeroshot/winclip_tokens.onnx` | 3.6 MB | WinCLIP: image → patch tokens (products with < 20 photos) |
23
+ | `zeroshot/winclip_encode.onnx` | 465 MB | WinCLIP: token sequence → embedding |
24
+ | `zeroshot/winclip_text.npy` | 5 KB | WinCLIP: "normal" / "anomalous" prompt embeddings |
25
+
26
+ ## Inputs and outputs
27
+
28
+ - **`wide_resnet50_l23.onnx`**: `image` float32 `(B, 3, 256, 256)` in **[0, 1]** (ImageNet normalization is inside the
29
+ graph) → `layer2` `(B, 512, 32, 32)`, `layer3` `(B, 1024, 16, 16)`. WideResNet-50-2 (torchvision ImageNet weights),
30
+ layers 2 and 3, as in PatchCore.
31
+ - **`winclip_tokens.onnx`**: `image` float32 `(B, 3, 240, 240)` in [0, 1] (CLIP normalization inside) → `tokens`
32
+ `(B, 226, 896)`: class + 15×15 patch tokens with position embeddings, after `ln_pre`.
33
+ - **`winclip_encode.onnx`**: `tokens` `(N, L, 896)` (any sequence length) → `pooled` `(N, 640)` projected class token,
34
+ `patch_tokens` `(N, L-1, 896)` after `ln_post`. The app feeds it whole images and 2×2 / 3×3 patch windows.
35
+ - **`winclip_text.npy`**: `(2, 640)` unit vectors: mean of the WinCLIP prompt ensemble for "object" (normal, anomalous).
36
+
37
+ CLIP is `ViT-B-16-plus-240` with `laion400m_e31` weights from OpenCLIP 4.2.2. The vision tower was split into the two
38
+ graphs so the backend can gather window tokens itself.
39
+
40
+ ## How they were made
41
+
42
+ Exported on Kaggle by the notebooks in the app repository (`notebooks/make_notebook.py` generates them):
43
+ `01_patchcore_mvtec_kaggle.ipynb` / `02_eval_backend_kaggle.ipynb` (backbone) and
44
+ `03_winclip_zeroshot_kaggle.ipynb` (WinCLIP, with an ONNX-vs-PyTorch check: minimum cosine 0.9999998).
45
+
46
+ ## Results (MVTec AD, 15 categories, CPU backend)
47
+
48
+ | | Image AUROC |
49
+ |---|---|
50
+ | PatchCore, all good photos | 98.4% |
51
+ | WinCLIP, 0 / 1 / 5 good photos | 88.6% / 93.0% / 94.3% |
52
+
53
+ ## SHA-256
54
+
55
+ ```
56
+ 3d37fdeb530ca539cd2da0b6674fbd9455ca90efd4a3f528449d404ab1093864 backbone/wide_resnet50_l23.onnx
57
+ 46ce03ca32dc59ef7a02595c0dd8073466c2286711fe529b73cce6ba74df420b zeroshot/winclip_tokens.onnx
58
+ 2e8f04810a917de96edd51b018d70f42a85b622d6b0e4000bc4505cd04640b71 zeroshot/winclip_encode.onnx
59
+ 9ab7d6fbe6ff903b3a9d871de76fc971480752c3b09c4ebe6986ed0af51b43db zeroshot/winclip_text.npy
60
+ ```
61
+
62
+ ## Licenses and credits
63
+
64
+ - Export code and this card: MIT.
65
+ - WideResNet-50-2 weights: [torchvision](https://github.com/pytorch/vision) (BSD-3-Clause), trained on ImageNet.
66
+ - CLIP weights: [OpenCLIP](https://github.com/mlfoundations/open_clip) (MIT) `ViT-B-16-plus-240`, trained on LAION-400M.
67
+ - Methods: Roth et al., *Towards Total Recall in Industrial Anomaly Detection* (PatchCore, CVPR 2022);
68
+ Jeong et al., *WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation* (CVPR 2023).