Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: s-lab-1.0
|
| 4 |
+
license_link: https://github.com/pq-yang/MatAnyone/blob/main/LICENSE
|
| 5 |
+
library_name: coreml
|
| 6 |
+
pipeline_tag: image-segmentation
|
| 7 |
+
tags:
|
| 8 |
+
- coreml
|
| 9 |
+
- core-ml
|
| 10 |
+
- ios
|
| 11 |
+
- macos
|
| 12 |
+
- apple
|
| 13 |
+
- on-device
|
| 14 |
+
- video-matting
|
| 15 |
+
- alpha-matting
|
| 16 |
+
- memory-network
|
| 17 |
+
- arxiv:2501.14677
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# MatAnyone — Core ML
|
| 21 |
+
|
| 22 |
+
*Video Matting, 2025*
|
| 23 |
+
|
| 24 |
+
Temporally consistent video matting. 5-model pipeline with memory propagation.
|
| 25 |
+
|
| 26 |
+
Core ML conversion of [pq-yang/MatAnyone](https://github.com/pq-yang/MatAnyone) for on-device inference on iPhone, iPad and Mac. Converted with `coremltools`; the packages are stateless, so all sequencing and buffering lives in your Swift code.
|
| 27 |
+
|
| 28 |
+
| | |
|
| 29 |
+
|---|---|
|
| 30 |
+
| Task | image segmentation |
|
| 31 |
+
| Upstream | [pq-yang/MatAnyone](https://github.com/pq-yang/MatAnyone) |
|
| 32 |
+
| Packages | 5 |
|
| 33 |
+
| Download size | 83 MB |
|
| 34 |
+
| Minimum iOS | 17.0 |
|
| 35 |
+
| Peak RAM | ~800 MB |
|
| 36 |
+
|
| 37 |
+
## Files
|
| 38 |
+
|
| 39 |
+
| File | Size | Compute units | SHA-256 |
|
| 40 |
+
|---|---:|---|---|
|
| 41 |
+
| `MatAnyone_encoder.mlpackage.zip` | 17 MB | `cpuAndGPU` | `97ffd6bc4611f9a3…` |
|
| 42 |
+
| `MatAnyone_mask_encoder.mlpackage.zip` | 16 MB | `cpuAndGPU` | `ba67559188ffc64d…` |
|
| 43 |
+
| `MatAnyone_read_first.mlpackage.zip` | 21 MB | `cpuOnly` | `34daf7227dbcec73…` |
|
| 44 |
+
| `MatAnyone_read.mlpackage.zip` | 21 MB | `cpuOnly` | `052e52c0ffb7ff9e…` |
|
| 45 |
+
| `MatAnyone_decoder.mlpackage.zip` | 8 MB | `cpuAndGPU` | `67136aa67000e604…` |
|
| 46 |
+
| **Total** | **83 MB** | | |
|
| 47 |
+
|
| 48 |
+
`compute_units` is not a suggestion -- it is the configuration the conversion was verified against. Moving a package to a different compute unit can silently change the numerics (FP16 attention overflow) or crash on the GPU.
|
| 49 |
+
|
| 50 |
+
## Download
|
| 51 |
+
|
| 52 |
+
```bash
|
| 53 |
+
hf download mlboydaisuke/coreml-zoo --include "matanyone/*" --local-dir ./matanyone
|
| 54 |
+
unzip './matanyone/matanyone/*.zip' -d ./matanyone
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## Use in Swift
|
| 58 |
+
|
| 59 |
+
```swift
|
| 60 |
+
import CoreML
|
| 61 |
+
|
| 62 |
+
let config = MLModelConfiguration()
|
| 63 |
+
config.computeUnits = .cpuAndGPU // as converted — see the table above
|
| 64 |
+
|
| 65 |
+
// Unzip the .mlpackage, drop it into your Xcode target and Xcode compiles it
|
| 66 |
+
// at build time:
|
| 67 |
+
let model = try MatAnyone_encoder(configuration: config)
|
| 68 |
+
|
| 69 |
+
// ...or compile a downloaded .mlpackage at runtime:
|
| 70 |
+
let compiled = try await MLModel.compileModel(at: mlpackageURL)
|
| 71 |
+
let model = try MLModel(contentsOf: compiled, configuration: config)
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
> This model is split into 5 Core ML packages that are driven in sequence from Swift. Load them one at a time, copy the outputs out of the `MLMultiArray` buffers and release each model before loading the next — two large Core ML models resident at once will OOM on an iPhone.
|
| 75 |
+
|
| 76 |
+
## Demo
|
| 77 |
+
|
| 78 |
+
- **Sample app** — [`sample_apps/MatAnyoneDemo`](https://github.com/john-rocky/CoreML-Models/tree/master/sample_apps/MatAnyoneDemo), a standalone SwiftUI project.
|
| 79 |
+
- **Models Zoo** — this model is downloadable and runnable inside the [Models Zoo app](https://apps.apple.com/app/id6762083207) on the App Store, no build required.
|
| 80 |
+
|
| 81 |
+
## Conversion
|
| 82 |
+
|
| 83 |
+
- Script: [`convert_matanyone.py`](https://github.com/john-rocky/CoreML-Models/blob/master/conversion_scripts/convert_matanyone.py)
|
| 84 |
+
- Pitfalls hit during conversion (FP16 overflow, ANE buffer limits, stride handling): [`docs/coreml_conversion_notes.md`](https://github.com/john-rocky/CoreML-Models/blob/master/docs/coreml_conversion_notes.md)
|
| 85 |
+
- Model index: [CoreML-Models](https://github.com/john-rocky/CoreML-Models)
|
| 86 |
+
|
| 87 |
+
## License
|
| 88 |
+
|
| 89 |
+
The conversion inherits the upstream license: **S-Lab License 1.0**.
|
| 90 |
+
See [https://github.com/pq-yang/MatAnyone/blob/main/LICENSE](https://github.com/pq-yang/MatAnyone/blob/main/LICENSE).
|
| 91 |
+
|
| 92 |
+
> Non-commercial use only.
|
| 93 |
+
|
| 94 |
+
## Credits
|
| 95 |
+
|
| 96 |
+
- Upstream authors: [pq-yang/MatAnyone](https://github.com/pq-yang/MatAnyone), 2025
|
| 97 |
+
- Core ML conversion: john-rocky (Daisuke Majima)
|