At a glance
| Upstream model | microsoft/swin-base-patch4-window7-224 |
|---|---|
| Loaded ONNX repo |
Xenova/swin-base-patch4-window7-224
(onnx/model_quantized.onnx)
|
| Pipeline task | image-classification Β· { top_k: 3β10 } (1,000 ImageNet-1k classes) |
| Architecture |
SwinForImageClassification β ~88M params, 4Γ4 patch partition, 7Γ7 shifted windows,
depths: [2, 2, 18, 2], heads [4, 8, 16, 32],
embed_dim: 128, hidden_size: 1024
|
| Image processor |
ViTFeatureExtractor β 224Γ224 bicubic resize, rescale 1/255,
ImageNet mean [0.485, 0.456, 0.406], std [0.229, 0.224, 0.225]
|
| Backend & size |
CPU WASM q8 β 97.32 MB (97,318,614 B:
97,248,189 B weights + 70,035 B config + 390 B preprocessor)
via shared @huggingface/transformers@3.7.5 in lib/webai.js
|
| License | Apache-2.0 (upstream weights and ONNX export) |
Live ImageNet-1k Classifier & Pixel Patch Inspector
Choose a verified starter photo, drop or pick any image file, press Ctrl/Cmd+V to paste from clipboard, or capture a live webcam snapshot. Inference runs locally inside a dedicated Web Worker.
Camera frames stay strictly on your device. Approve permission when prompted, then capture a snapshot.
Camera idle.
Initialising model loaderβ¦
No photo selected yet.
| Channel | Rescaled mean (0β1) | ImageNet target ΞΌ / Ο | Normalised tensor mean |
|---|---|---|---|
| Select an image to inspect 224Γ224 tensor statistics. | |||
| Rank | ImageNet-1k label | Probability | Gap from Top-1 |
|---|---|---|---|
| Run Swin-Base to populate the Top-K ImageNet-1k prediction table. | |||
Raw pipeline output (exact ImageNet-1k label/score pairs)
[]
How Swin-Base scales past Swin-Tiny & ViT-Base
Both Swin-Tiny and Swin-Base partition a 224Γ224 input into 3,136 patches of 4Γ4 pixels
(56Γ56 tokens) and compute self-attention inside 7Γ7 shifted windows.
Swin-Base expands initial embedding width from 96 β 128
(hidden_size: 768 β 1024) and deepens Stage 3 from 6 β 18 blocks
([2, 2, 18, 2]), delivering ~3Γ parameter capacity (88M vs 28.3M)
with linear spatial scaling.
| Architecture | Depths / Core primitive | Embed β Hidden | Params | WASM q8 footprint |
|---|---|---|---|---|
| Swin-Base (224) | [2, 2, 18, 2] Β· 4Γ4 patches + 7Γ7 shifted windows |
128 β 1024 | ~88M | 97.32 MB |
| Swin-Tiny (224) | [2, 2, 6, 2] Β· 4Γ4 patches + 7Γ7 shifted windows |
96 β 768 | ~28.3M | 32.39 MB |
| ViT-Base/16 | 12 layers Β· 16Γ16 tokens + global self-attention | 768 β 768 | 86.6M | ~87 MB |
| ConvNeXt V2 Tiny | [3, 3, 9, 3] Β· 7Γ7 depthwise conv + GRN |
96 β 768 | 28.6M | 29.54 MB |
How the API works
Transformers.js runs Swin-Base through the standard image-classification pipeline inside a Web Worker.
ViTFeatureExtractor resizes inputs to 224Γ224 with bicubic interpolation and normalises ImageNet RGB channels:
import { pipeline } from "https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.7.5";
const classifier = await pipeline("image-classification", "Xenova/swin-base-patch4-window7-224", {
device: "wasm",
dtype: "q8",
});
const results = await classifier(image, { top_k: 5 });
See inside the code
Inspect the exact ES modules powering this page β off-main-thread inference, tensor diagnostics, and ranking maths.
Show the code β worker.js: ensureLoaded() (shared 3.7.5 WASM q8 + epoch guards)
Show the code β worker.js: classifyImage() (white-flatten, top_k, real nanCount)
Show the code β swin-base-core.mjs: computePreprocessStats() & analyzeClassification()
Explore the 5-route use-case ladder
Basics: Window Ablation & Quantization
Probe 7Γ7 crop/scale/orientation ablation, multi-sample calibration/entropy curves, and q8 vs q4/fp16 live.
Practical: Batch Image Triage
Auto-tag multi-file photo batches with Cancel, live tag search, histogram, and OWASP CSV + JSON export.
Wild: OOD & Corruption Stress Lab
Stress-test occlusion, Gaussian blur, 200% contrast, color invert, sensor noise, and synthetic OOD textures.
Multi-model: Swin-Tiny vs Swin-Base
Compare 28.3M Swin-Tiny (32.39 MB) vs 88M Swin-Base (97.32 MB) live on identical frames and crops.