Skip to content
image-classification Β· basics Depths [2, 2, 18, 2] Β· 7Γ—7 Crop/Scale Ablation Calibration Curve Β· q8 vs q4/fp16 License: Apache-2.0

Basics: Shifted-Window Crop/Scale Ablation, Calibration & Quantization

Explore Swin-Base's 4-stage hierarchical pyramid (56β†’28β†’14β†’7 with embed_dim: 128 and hidden_size: 1024), test how 7Γ—7 window shifts, tight center crops, and orientation affect predictions, measure probability calibration & entropy across curated samples, and benchmark q8 (97.32 MB) vs q4 (64.33 MB) or fp16 (181.95 MB).

1 Β· Hierarchical [2, 2, 18, 2] shifted-window pyramid

Exact stage geometry from Xenova/swin-base-patch4-window7-224/config.json: patch_size: 4, window_size: 7, embed_dim: 128, depths: [2, 2, 18, 2], num_heads: [4, 8, 16, 32], hidden_size: 1024.

2 Β· Shifted-window (7Γ—7) crop, scale & orientation ablation

Select a starter photo, upload/drop/paste your own, or capture a webcam snapshot, then run all 6 ablation framing probes (100%, 75% crop, 50% crop, +14 px half-window shift, horizontal mirror, 90Β° rotation) inside the Web Worker.

Initialising model loader…

Select a photo to inspect window alignment.

Active transform–
Top-1 prediction–
Top-1 confidence–
Margin (1stβˆ’2nd)–
Shannon entropy–
NaN / invalid0
6-step 7Γ—7 window crop, scale, shift, mirror, and rotation ablation results
Probe Top-1 prediction Confidence Margin Entropy Latency
Run the 6-step ablation sweep to populate comparison rows.

3 Β· Top-K probability calibration & entropy curve across samples

Sweeps 5 diverse curated ImageNet photos sequentially (yielding cleanly between passes via yieldToMain()) to measure Swin-Base's probability concentration (Top-1, Top-5 mass, margin, and Shannon entropy in bits).

Ready once Swin-Base loads.

Samples measured–
Mean Top-1 prob–
Mean margin–
Mean Top-5 mass–
Mean entropy–
Per-sample probability calibration & entropy breakdown
Sample Top-1 prediction Top-1 prob Top-5 mass Margin Entropy
Click "Measure calibration across 5 samples" to run the multi-sample curve.

4 Β· Live q8 vs q4 / fp16 quantization comparison

Xenova/swin-base-patch4-window7-224 provides q8 (97.32 MB), q4 (64.33 MB), and fp16 (181.95 MB). Comparison weights download ONLY when you click below, benchmark both precisions on the active input, and restore q8 afterwards.

Ready once q8 loads β€” comparison downloads only on click.

Top-1 agreement–
Target prob shift–
Top-5 L1 drift–
q8 vs alt latency–

Click "Compare q8 vs selected precision" to benchmark INT8 vs INT4/FP16 live.

See inside the code

Show the code β€” swin-base-core.mjs: SWIN_BASE_STAGES ([2, 2, 18, 2] geometry)
Show the code β€” swin-base-core.mjs: ABLATION_SPECS, compareQuantRuns() & summarizeCalibrationCurve()

References