BiRefNet-lite 在手机 NPU 上跑 1024px 抠图,Snapdragon 8 Elite Gen 5 上 23.7 ms
BiRefNet-lite at 1024px fully on a phone NPU: 23.7 ms on Snapdragon 8 Elite Gen 5, int8, open weights + writeup [P]
独立研究者将 BiRefNet-lite 重写为可在手机 NPU 上运行的版本,在 Snapdragon 8 Elite Gen 5 上生成 1024×1024 掩码耗时 23.7 ms,int8 量化,全部 2060 层都在 NPU 上。
I wanted tap-to-lift subject cutout in my Android gallery app, running fully on the NPU. BiRefNet-lite gave the best masks of the open models I tried, but it doesn't compile to a phone NPU. The decoder has 20 deformable convs, Swin uses 5D/6D tensors, the shifted windows use a cyclic roll, and 1024px activations don't fit in on-chip memory. So I rewrote it.
What I did:
- Exact graph rewrites (same output as the original): 4D window partition, roll-free shifted windows with a fixed mask, channel-split convs, attention one head at a time.
- Architecture changes: plain convs instead of deformable, 640px backbone with a 1024px mask from two inputs, a slim full-res tail, one global window in Swin stage 4.
- QAT distillation through the exported NPU graph, all 8-bit.
Results:
- 23.7 ms for a 1024×1024 mask on a Galaxy S26 (8 Elite Gen 5), 31.1 ms on an S25, 182 ms on a mid-range 7 Gen 1. All 2,060 layers on the NPU.
- Stock BiRefNet-lite on the same phones: out of memory at 1024. At 512 it falls back to CPU, 677 ms and 2.1 GB peak.
- Compiles AOT for 42 Snapdragon chips as one NPU partition (one GitHub Actions job per chip).
- On held-out ECSSD and DUT-OMRON (neither model trained on them), the int8 model matches its fp32 teacher in S-measure (0.939 vs 0.938, 0.830 vs 0.826). Edges are a bit softer.
PS. watch your gates when distilling. A sigmoid gate on the deepest decoder branch saturated to ~1e-11 and the branch went dead. The teacher relies on it (gate ~0.46), but the student's mask loss showed nothing because the rest of the decoder compensated. Known failure mode, easy to miss. I restored the branch from the teacher and kept it open with a feature loss.
Limitations:
it loses 0.017 S-measure on DIS-VD fine structures (wires, fences). Six public models beat it on DUT-OMRON. No MediaTek or Tensor support. I haven't measured power yet. Full comparison against 17 public models plus Apple Vision and ML Kit is in the paper.
- Paper: https://doi.org/10.5281/zenodo.24152780
- Weights + 42 compiled chip files: https://huggingface.co/subhashhhhhh/lumen-cutout
- Code (rewrites, conversion, QAT, training, compile workflow): https://github.com/subhashhhhhh/lumen-cutout
MIT licensed, same as BiRefNet. Happy to answer questions about the QNN/LiteRT side. That's where most of the pain was.
Also: I'm an independent researcher and need a CS endorsement to put this on arXiv. If you've published in CS and think the work holds up, a DM would mean a lot.
submitted by /u/subhashg547
[link] [留言]
来源:r/MachineLearning · reddit.com