image-segmentation · basics Threshold Sweep · Probability Histogram · q8 vs fp32 0.22 MB q8 vs 0.46 MB fp32 License: Apache-2.0

Basics: Inside a 224 KB MobileNetV3-Small Segmentation Head

Explore how the continuous [1, 1, 256, 256] probability field responds across thresholds 0.1 → 0.9, inspect where pixels cluster in the 10-bin histogram, and measure the real per-pixel difference between INT8 quantized (q8, 0.22 MB) and full-precision (fp32, 0.46 MB) ONNX weights.

1 · Live alpha threshold sweep (0.1 → 0.9) & histogram

Initialising model loader…

Foreground coverage curve across thresholds 0.1 → 0.9 (green dot = selected threshold).

Bimodal distribution: confident background (0.0–0.1) vs person (0.9–1.0) vs edge hair/clothing.

Alpha threshold sweep across all 65,536 (256×256) matte pixels
Threshold Foreground % Background % Boundary band (±0.1) Coverage
Run inference above to populate the threshold sweep.

2 · Real q8 (0.22 MB) vs fp32 (0.46 MB) quantization diff

onnx-community/mediapipe_selfie_segmentation publishes both onnx/model_quantized.onnx (q8, 224,004 B) and onnx/model.onnx (fp32, 462,352 B). Run both weights sequentially in the worker to measure exact IoU, Dice, and amplified per-pixel quantization error.

Mask IoU (@ thr)–
Dice coefficient–
Mean |q8 − fp32|–
Max |q8 − fp32|–
Flipped pixels–
q8 / fp32 latency–
NaN / invalid0

q8 matte (0.22 MB)

fp32 matte (0.46 MB)

5× amplified |q8 − fp32| difference map

See inside the code

Show the code — selfie-core.mjs: computeThresholdSweep() (0.1 → 0.9 coverage & boundary band)
Show the code — selfie-core.mjs: computeMaskIoU() (IoU, Dice, MAE, and flipped pixel %)
Show the code — selfie.js: drawThresholdCurveCanvas() (token-styled threshold curve)

References