Skip to content

pixel-lab: offer f16 for MediaPipe and MODNet - #3521

Draft
czoli1976 wants to merge 1 commit into
sonos:mainfrom
czoli1976:perf/pixel-lab-f16-option
Draft

czoli1976 wants to merge 1 commit into
sonos:mainfrom
czoli1976:perf/pixel-lab-f16-option

Conversation

@czoli1976

Copy link
Copy Markdown
Contributor

Pixel Lab already runs the Longpipe mattes with an f16 body: f32_to_f16 with keep_io, plus TRACT_WGPU_ALLOW_F16_ACCUMULATION scoped to prepare. This offers the same path for MediaPipe and MODNet as an opt-in.

Changes:

  • models.mjs: an f16Option flag (set on mediapipe, mediapipe-landscape and modnet) and offersF16() / runsF16(). Longpipe stays always-f16 (f16Body); RVM keeps its fp16 file.
  • worker.js: passes runsF16(model, f16) to Segmenter::create. No Rust change: create already takes the f16_body flag.
  • main.js / index.html: a "Run the model in f16" checkbox, shown only for those three models and off by default. Changing it restarts the camera session. The status line says "f16" when it is on.

Behaviour change: none by default. Lower precision is opt-in, per the repo's precision rule.

Validation:

  • node --test site/*.test.mjs: all pass, plus a new test of which models offer f16 and how runsF16 treats Longpipe and RVM.
  • Chrome 158 / Apple M1 Pro, fake camera (20 fps clip, 640×360 capture):
Model f32 mask compute f16 mask compute GPU ops f32 → f16
MODNet 512×288 27 ms 22 ms 196 → 194
MediaPipe 256×144 5 ms 4 ms 86 → 78
  • On the test clip the f16 masks look the same as the f32 ones (screenshots compared). No per-pixel alpha comparison was made.

Not tested: a real camera, Safari and Firefox.

🍍

🤖 Generated with Claude Code

Only the Longpipe mattes could run in f16. MediaPipe and MODNet now offer the same f16 body,
f16 storage and accumulation with an f32 camera and mask, behind a "Run the model in f16"
option that is off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant