luweigen's picture
Publish the app code that runs these models (app/)
c6d2f7b verified
|
Raw History Blame Contribute Delete
3.1 kB
---
license: apache-2.0
tags:
- onnx
- inpainting
- android
- qnn
---
# Moebius inpainting — ONNX models prepared for Android
Derived from [simonw/Moebius-ONNX](https://huggingface.co/simonw/Moebius-ONNX) (ONNX export of [hustvl/Moebius](https://github.com/hustvl/Moebius), Apache-2.0)
for the native Android app in the `onnx-android` project. Files are downloaded by the app and checked against sha256 values compiled into the APK.
| Set | Files | For |
|---|---|---|
| `gpu+htp` | `hyb1.json` + `hyb1.s*` (batch-1 hybrid chain) + `unet.b1.fp16x.onnx` + the `vae_*.static_ctx` files | Snapdragon 8 Elite, default there. The two classifier-free-guidance branches run in parallel: uncond on the NPU+CPU hybrid chain, cond on the GPU (both batch 1) |
| `gpu` | `unet.fp16x.onnx` + the `vae_*.static_ctx` files of `htp` | Snapdragon 8 Elite (SM8750) only, default there. UNet (fp16, cross-attention kept fp32) runs whole on the QNN GPU backend (Adreno 830); the app builds the GPU context binary on the device on first run. VAE on the NPU |
| `htp` | `hyb.json` + `hyb.s*.cpu.onnx` (CPU segments) + `hyb.s*.htp_ctx.onnx` / `_ctx_qnn.bin` (QNN HTP context binaries), `vae_*.static_ctx.onnx` / `_ctx_qnn.bin` | Snapdragon 8 Elite (SM8750, HTP v79) only. UNet split into 13 segments: 64×64 attention blocks and the timestep embedding on CPU, the rest on the NPU. Context binaries compiled offline with onnxruntime-qnn 2.7.0 (QNN 2.51); the device needs qnn-runtime ≥ 2.51 |
| `cpu-int8` | `unet.int8r.onnx` + the VAE of `cpu` | Any device, optional: convolutions statically quantized to int8 (QDQ; first/last and residual-block convs kept fp32). About 2× faster on ARM CPUs without dot-product instructions, slightly smoother inpainted texture |
| `cpu` | `unet.einsum.onnx`, `vae_encoder.static.onnx`, `vae_decoder.static.onnx` | Any device, CPU EP, fp32. Static shapes (UNet batch 2), Einsum rewritten to MatMul, condition embedding replaced by a `context` input (2×10×3072, shipped in the APK) |
Changes from the original graphs: static shapes, `input_ids` → `context` input, Einsum → Transpose/Reshape/MatMul, normalization pre-scaling (HTP fp16 range), graph splitting. Weights are unchanged except for the fp16 conversion of `unet.fp16x.onnx`.
## `app/` — Android code that runs these models
[`app/`](https://huggingface.co/luweigen/moebius-onnx-android/tree/main/app) holds the parts of the Android app that load and run the models above: the inpainting pipeline (noise, DDIM, classifier-free guidance, VAE scaling), image preparation and paste-back, ONNX Runtime / QNN session setup (HTP context binaries, the hybrid NPU+CPU chain, the GPU context cache, the parallel CFG branches), the download/sha256 manifest, and the small inputs the graphs need that are not model files (`context.bin`, benchmark tensors).
It is reference code, not a complete buildable project (the UI, resources and build tooling are left out). See [app/README-HF.md](https://huggingface.co/luweigen/moebius-onnx-android/blob/main/app/README-HF.md) for how the pieces fit together and the file list.