Skip to content
image-classification Β· vision 88M Params Β· Depths [2, 2, 18, 2] Β· 7Γ—7 Windows WASM q8 Β· 97.32 MB License: Apache-2.0

Swin-Base (Patch4 Window7 224) β€” 88M Hierarchical ImageNet-1k Classifier

Microsoft's Swin-Base scales the shifted-window Transformer to 88M parameters with embed_dim: 128, depths: [2, 2, 18, 2], and hidden_size: 1024 β€” tripling Stage-3 depth (18 blocks vs Swin-Tiny's 6) across a 56Γ—56 β†’ 28Γ—28 β†’ 14Γ—14 β†’ 7Γ—7 spatial pyramid for calibrated 1,000-class ImageNet-1k classification in 97.32 MB CPU WASM q8.

At a glance

Swin-Base model specification and runtime grounding
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.

Initialising model loader…

No photo selected yet.

Top-1 class–
Top-1 score–
Top-1 vs Top-2 margin–
Shannon entropy–
Latency–
Backend / dtypewasm Β· q8
NaN / invalid0
224Γ—224 bicubic preprocessing & ImageNet normalisation inspection
Channel Rescaled mean (0–1) ImageNet target ΞΌ / Οƒ Normalised tensor mean
Select an image to inspect 224Γ—224 tensor statistics.
Top-K ImageNet-1k predictions
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.

Architectural comparison of browser ImageNet-1k classifiers
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

References & model card