nklockiewicz's picture
README: add SAM 3 section (shapes, timings, SAM License)
689f683 verified
|
Raw History Blame Contribute Delete
6.49 kB
---
license: apache-2.0
base_model:
- hustvl/Moebius
- facebook/sam3
tags:
- executorch
- react-native
- on-device
- inpainting
- segmentation
- coreml
- xnnpack
---
# react-native-executorch demo models
ExecuTorch exports of models used in [react-native-executorch](https://github.com/software-mansion/react-native-executorch) demo apps.
## moebius-eraser
[Moebius](https://github.com/hustvl/Moebius) (Duan and Xu et al., ECCV 2026), a 0.22B latent-diffusion inpainting model from HUST and VIVO AI Lab, exported to ExecuTorch for on-device object removal.
| file | backend | precision | size |
|---|---|---|---|
| `moebius-eraser/coreml/moebius_vae_encoder.pte` | CoreML | fp16 | 69 MB |
| `moebius-eraser/coreml/moebius_unet.pte` | CoreML | fp16 | 447 MB |
| `moebius-eraser/coreml/moebius_vae_decoder.pte` | CoreML | fp16 | 100 MB |
| `moebius-eraser/xnnpack/moebius_vae_encoder.pte` | XNNPACK | fp32 | 137 MB |
| `moebius-eraser/xnnpack/moebius_unet.pte` | XNNPACK | fp32 | 905 MB |
| `moebius-eraser/xnnpack/moebius_vae_decoder.pte` | XNNPACK | fp32 | 198 MB |
The three graphs are meant to be driven by a DDIM sampling loop on the JavaScript side.
- `moebius_vae_encoder`: `(1,3,512,512)` image in [-1,1] -> `(1,4,64,64)` latents, already scaled by 0.13025
- `moebius_unet`: `(noisy_latents, mask64, masked_latents, timestep, guidance)` -> `(1,4,64,64)` predicted noise. Classifier-free guidance is baked into the graph as an internal batch of 2, so one call per denoising step.
- `moebius_vae_decoder`: `(1,4,64,64)` latents -> `(1,3,512,512)` image in [0,1]
Spatial dimensions are static at 512x512 (64x64 latent): the cross-attention positional embedding is a learned parameter tied to the training resolution.
Reference implementation, export script and sampler: [on-device-eraser demo app](https://github.com/NorbertKlockiewicz/on-device-eraser).
## License and credit
Moebius weights and code are Apache 2.0, and these exports inherit that license. The VAE comes from [PixelHacker](https://huggingface.co/hustvl/PixelHacker) by the same authors.
```
@inproceedings{DuanAndXu2026Moebius,
title={Moebius: 0.2B Lightweight Image Inpainting Framework with 10B-Level Performance},
author={Kangsheng Duan and Ziyang Xu and Wenyu Liu and Xiaohu Ruan and Xiaoxin Chen and Xinggang Wang},
year={2026},
booktitle={European Conference on Computer Vision (ECCV)}
}
```
## da3-scanner
ExecuTorch exports of [Depth Anything 3](https://github.com/bytedance-seed/depth-anything-3) (ByteDance Seed, ICLR 2026) any-view models, for the [on-device 3D scanner demo app](https://github.com/NorbertKlockiewicz/on-device-3d-scanner): 8 photos in, per-view depth, confidence and camera poses out in one forward pass, no SfM and no per-scene optimization.
Layout: `da3-scanner/coreml/` (iOS) and `da3-scanner/xnnpack/` (Android and CPU). All graphs are static at 8 views of 560x420 (portrait), ImageNet-normalized RGB, input `(1,8,3,560,420)`:
- `da3_base_8v_560x420_coreml_fp16_gpu.pte` (480MB): DA3-BASE, fp16, compute units pinned to CPU_AND_GPU. The pin is deliberate: the ANE compiler crashes the host process on this graph, while the GPU runs it in ~3.1s on an iPhone 16 Pro.
- `da3_small_8v_560x420_coreml_fp32.pte` (382MB): DA3-SMALL, ~2.0s on the same phone, ANE-safe.
- `da3_base_8v_560x420_xnnpack.pte` (413MB) and `da3_small_8v_560x420_xnnpack.pte` (105MB): fp32 CPU builds.
Outputs per view: depth `(1,8,560,420)`, confidence `(1,8,560,420)`, and a 9-float pose encoding (translation, quaternion xyzw, vertical/horizontal FOV) relative to view 0. Export script and the pose decoding: see the demo repo.
DA3-SMALL and DA3-BASE weights and code are Apache 2.0, and these exports inherit that license.
```
@article{depthanything3,
title={Depth Anything 3: Recovering the visual space from any views},
author={Haotong Lin and Sili Chen and Jun Hao Liew and Donny Y. Chen and Zhenyu Li and Guang Shi and Jiashi Feng and Bingyi Kang},
journal={arXiv preprint arXiv:2511.10647},
year={2025}
}
```
## sam3
[SAM 3](https://huggingface.co/facebook/sam3) (Meta, 848M parameters), text-prompted instance segmentation ("segment every X"), exported to ExecuTorch for the [on-device SAM 3 demo app](https://github.com/NorbertKlockiewicz/on-device-sam3). Type a word, every instance is segmented on the phone.
Layout: `sam3/coreml/` (iOS). All graphs are static at a 672x672 input (SAM 3 natively uses 1008; 672 finds the same instances on 6 of 7 test prompts and keeps the ViT on the Neural Engine). Core ML fp16.
| file | runs | size | iPhone 16 Pro |
|---|---|---|---|
| `sam3/coreml/sam3_vision0_672_coreml.pte` | per photo | 230 MB | ~370 ms |
| `sam3/coreml/sam3_vision1_672_coreml.pte` | per photo | 224 MB | ~330 ms |
| `sam3/coreml/sam3_vision2_672_coreml.pte` | per photo | 224 MB | ~330 to 500 ms |
| `sam3/coreml/sam3_vision3_672_coreml.pte` | per photo | 238 MB | ~330 ms |
| `sam3/coreml/sam3_head_672_coreml.pte` | per prompt | 105 MB | ~170 to 300 ms |
| `sam3/coreml/sam3_text_672_coreml.pte` | per prompt | 707 MB | ~11 to 20 ms |
| `sam3/coreml/sam3_tokenizer.json` | | 4 MB | |
- `sam3_vision0..3`: the 32-layer ViT in four 8-layer chunks (the ANE compiler rejects the whole ViT as one program). `vision0` takes `(1,3,672,672)` pixels in [-1,1] (`x/127.5 - 1`, photo stretched to square) and returns `(1,48,48,1024)`; `vision1` and `vision2` map that to the same shape; `vision3` adds the FPN neck and returns 3 maps `(1,256,192,192)`, `(1,256,96,96)`, `(1,256,48,48)`.
- `sam3_text`: CLIP text encoder, `input_ids` and `attention_mask` `(1,32)` int64 (CLIP tokenizer, padded with 49407) -> `(1,32,256)`.
- `sam3_head`: `(fpn0, fpn1, fpn2, text_features, attention_mask)` -> masks `(1,200,192,192)` logits, boxes `(1,200,4)` normalized cxcywh, logits `(1,200)`, presence `(1,1)`. Score = `sigmoid(logit) * sigmoid(presence)`. FPN position encodings are baked in.
Verified end to end against PyTorch on real photos: identical instances and scores, mask IoU 0.994 to 1.0.
These exports are derivatives of the SAM 3 weights and are distributed under Meta's SAM License, a copy of which is in `sam3/LICENSE`. They are not covered by the Apache 2.0 license of the other folders.
```
@misc{carion2025sam3segmentconcepts,
title={SAM 3: Segment Anything with Concepts},
author={Nicolas Carion and others},
year={2025},
eprint={2511.16719},
archivePrefix={arXiv}
}
```