Add the speech-to-motion flow transformer step (fp16/fp32) for timing; update card
Browse filesFiles changed (3)
- README.md+7-2
- flow_step_fp16.onnxAdded+3
- flow_step_fp32.onnxAdded+3
22 unmodified lines232425262728282930313233343534363738393 unmodified lines43444546474849505122 unmodified lines|---|---|---|| `encoder_fp16.onnx` / `encoder_fp32.onnx` | portrait (1×3×512×512, values in [-1,1]) → identity style `x_r` (512) + 7 feature maps; run once per portrait | 44 / 87 MB || `decoder_fp16.onnx` / `decoder_fp32.onnx` | style `wa` (512) + the 7 feature maps → one 512×512 frame; run per frame (batch 1) | 49 / 94 MB || `flow_step_fp16.onnx` / `flow_step_fp32.onnx` | one pass of the 8-layer speech-to-motion transformer with KV cache (2 guidance branches × 12 tokens); inputs `x, c, wr, freqs, ada, fada` + per-layer caches `sk/sv/ck/cv`, output `y`. For timing now; the sampler around it is not published yet | 272 / 544 MB || `motion_basis_512x20.f32` | the 512×20 orthonormal motion basis (float32, row-major): `wa = x_r + basis @ lambda` for a 20-number motion vector `lambda` | 41 KB |
Not included: the speech-to-motion flow transformer, wav2vec2, and the voice/chat parts of the original pipeline.Not included: wav2vec2, the sampler/timestep/audio-conditioning pieces around the flow step, and the voice/chat parts of the original pipeline.
## Conversion notes (what mattered)- The decoder's per-sample modulated convolution is rewritten as `conv(x · style) · demod` (the same algebra as `mlx_port/decoder_fast_torch.py` in [AvatarVoice](https://github.com/johnrobinsn/AvatarVoice)); the original grouped form does not export cleanly.- **fp16 keeps the image warp (`grid_sample`) in fp32.** A fully fp16 decoder breaks the picture (about 4 dB PSNR); with the warp in fp32 it is visually lossless.- Float→float `Cast` nodes on constants are folded away (`convert/fold_casts.py`): ONNX Runtime Web's WebGPU backend otherwise refuses to build the session ("Provider type for Cast node is not set").- The flow step uses the *legacy* exporter (the dynamo one silently gets 3 of 12 frames wrong), with attention written as explicit softmax plus a mask and a "row has any visible key" factor to match torch's zeros for fully masked rows (this also removes `IsNaN`, which WebGPU lacks).- Exported with the dynamo exporter, opset 19 (`GridSample` is available for opset 16–19), single-file (no external data).- Encoder/decoder were exported with the dynamo exporter, opset 19 (`GridSample` is available for opset 16–19), single-file (no external data).
## Verification (CPU/software reference, real weights, one portrait)| Check | Result |3 unmodified lines| decoder fp16 ONNX (ORT CPU) vs fp32 original | max abs 0.007, mean abs 0.0003 || fp16 encoder → fp16 decoder chain (PyTorch) vs fp32 | 66.2 dB PSNR (8-bit display rounding alone is 58.6 dB) || encoder fp32 ONNX vs original | max abs 1e-5 || flow step fp32 ONNX (ORT CPU) vs original PyTorch, real weights, 8 layers | max abs 2e-4 on outputs up to 12 || flow step fp32 on ORT-Web **WebGPU** (software adapter) vs ORT-Web CPU | max abs 7e-5, no CPU fallbacks || flow step fp16 ONNX (ORT CPU) vs fp32 original | mean relative error 0.46%, max abs 0.19 (single pass, random inputs). Not yet checked through the full 9-pass sampler, where rounding can compound |
Not verified here: speed or fp16 behaviour on a physical GPU (no GPU was available). The demo page measures that on the visitor's machine and falls back to fp32 automatically if fp16 is rejected.
123version https://git-lfs.github.com/spec/v1oid sha256:51e310c50cdfcb9a80e3c4dcb43923c32f7ea414ec6754a8ef223eef4f642fabsize 272326677123version https://git-lfs.github.com/spec/v1oid sha256:b4f5f4e3fa21b25d3e03eaa46995e50a8d1f757f49899e50afa5ca1f360e0338size 544413845README.md+7-2
flow_step_fp16.onnxAdded+3
flow_step_fp32.onnxAdded+3