vision-qc-models / README.md
Fushi21's picture
Model card
37b8db7 verified
|
Raw History Blame Contribute Delete
3.33 kB
metadata
license: mit
library_name: onnx
pipeline_tag: image-classification
tags:
  - anomaly-detection
  - visual-inspection
  - patchcore
  - winclip
  - onnx

Vision QC models

ONNX models used by Vision QC, a visual defect inspection app that learns from good photos only and runs on a CPU. Download them with the app's scripts/download_models.py (checks the SHA-256 below), or place them by hand under the app's models/ folder with the same paths.

File Size Used for
backbone/wide_resnet50_l23.onnx 99 MB PatchCore feature extractor (required)
zeroshot/winclip_tokens.onnx 3.6 MB WinCLIP: image → patch tokens (products with < 20 photos)
zeroshot/winclip_encode.onnx 465 MB WinCLIP: token sequence → embedding
zeroshot/winclip_text.npy 5 KB WinCLIP: "normal" / "anomalous" prompt embeddings

Inputs and outputs

  • wide_resnet50_l23.onnx: image float32 (B, 3, 256, 256) in [0, 1] (ImageNet normalization is inside the graph) → layer2 (B, 512, 32, 32), layer3 (B, 1024, 16, 16). WideResNet-50-2 (torchvision ImageNet weights), layers 2 and 3, as in PatchCore.
  • winclip_tokens.onnx: image float32 (B, 3, 240, 240) in [0, 1] (CLIP normalization inside) → tokens (B, 226, 896): class + 15×15 patch tokens with position embeddings, after ln_pre.
  • winclip_encode.onnx: tokens (N, L, 896) (any sequence length) → pooled (N, 640) projected class token, patch_tokens (N, L-1, 896) after ln_post. The app feeds it whole images and 2×2 / 3×3 patch windows.
  • winclip_text.npy: (2, 640) unit vectors: mean of the WinCLIP prompt ensemble for "object" (normal, anomalous).

CLIP is ViT-B-16-plus-240 with laion400m_e31 weights from OpenCLIP 4.2.2. The vision tower was split into the two graphs so the backend can gather window tokens itself.

How they were made

Exported on Kaggle by the notebooks in the app repository (notebooks/make_notebook.py generates them): 01_patchcore_mvtec_kaggle.ipynb / 02_eval_backend_kaggle.ipynb (backbone) and 03_winclip_zeroshot_kaggle.ipynb (WinCLIP, with an ONNX-vs-PyTorch check: minimum cosine 0.9999998).

Results (MVTec AD, 15 categories, CPU backend)

Image AUROC
PatchCore, all good photos 98.4%
WinCLIP, 0 / 1 / 5 good photos 88.6% / 93.0% / 94.3%

SHA-256

3d37fdeb530ca539cd2da0b6674fbd9455ca90efd4a3f528449d404ab1093864  backbone/wide_resnet50_l23.onnx
46ce03ca32dc59ef7a02595c0dd8073466c2286711fe529b73cce6ba74df420b  zeroshot/winclip_tokens.onnx
2e8f04810a917de96edd51b018d70f42a85b622d6b0e4000bc4505cd04640b71  zeroshot/winclip_encode.onnx
9ab7d6fbe6ff903b3a9d871de76fc971480752c3b09c4ebe6986ed0af51b43db  zeroshot/winclip_text.npy

Licenses and credits

  • Export code and this card: MIT.
  • WideResNet-50-2 weights: torchvision (BSD-3-Clause), trained on ImageNet.
  • CLIP weights: OpenCLIP (MIT) ViT-B-16-plus-240, trained on LAION-400M.
  • Methods: Roth et al., Towards Total Recall in Industrial Anomaly Detection (PatchCore, CVPR 2022); Jeong et al., WinCLIP: Zero-/Few-Shot Anomaly Classification and Segmentation (CVPR 2023).