mlboydaisuke commited on
Commit
ecf510c
·
verified ·
1 Parent(s): 23ee733

Add model card

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: coreml
4
+ pipeline_tag: mask-generation
5
+ tags:
6
+ - coreml
7
+ - core-ml
8
+ - ios
9
+ - macos
10
+ - apple
11
+ - on-device
12
+ - segment-anything
13
+ - sam
14
+ - promptable-segmentation
15
+ - arxiv:2306.14289
16
+ ---
17
+
18
+ # MobileSAM — Core ML
19
+
20
+ *Segment Anything, 2023*
21
+
22
+ Lightweight Segment Anything. Tap any point to generate a segmentation mask. ViT-Tiny encoder + lightweight decoder. ~60× smaller than SAM.
23
+
24
+ Core ML conversion of [ChaoningZhang/MobileSAM](https://github.com/ChaoningZhang/MobileSAM) 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.
25
+
26
+ | | |
27
+ |---|---|
28
+ | Task | mask generation |
29
+ | Upstream | [ChaoningZhang/MobileSAM](https://github.com/ChaoningZhang/MobileSAM) |
30
+ | Packages | 1 |
31
+ | Download size | 19 MB |
32
+ | Minimum iOS | 17.0 |
33
+ | Peak RAM | ~300 MB |
34
+
35
+ ## Files
36
+
37
+ | File | Size | Compute units | SHA-256 |
38
+ |---|---:|---|---|
39
+ | `MobileSAM.zip` | 19 MB | `all` | `0d8d48cb90a48cd8…` |
40
+ | **Total** | **19 MB** | | |
41
+
42
+ `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.
43
+
44
+ ## Download
45
+
46
+ ```bash
47
+ hf download mlboydaisuke/coreml-zoo --include "mobilesam/*" --local-dir ./mobilesam
48
+ unzip './mobilesam/mobilesam/*.zip' -d ./mobilesam
49
+ ```
50
+
51
+ ## Use in Swift
52
+
53
+ ```swift
54
+ import CoreML
55
+
56
+ let config = MLModelConfiguration()
57
+ config.computeUnits = .all // as converted — see the table above
58
+
59
+ // Unzip the .mlpackage, drop it into your Xcode target and Xcode compiles it
60
+ // at build time:
61
+ let model = try MobileSAM.zip(configuration: config)
62
+
63
+ // ...or compile a downloaded .mlpackage at runtime:
64
+ let compiled = try await MLModel.compileModel(at: mlpackageURL)
65
+ let model = try MLModel(contentsOf: compiled, configuration: config)
66
+ ```
67
+
68
+ ## Demo
69
+
70
+ - **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.
71
+
72
+ ## Conversion
73
+
74
+ - 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)
75
+ - Model index: [CoreML-Models](https://github.com/john-rocky/CoreML-Models)
76
+
77
+ ## License
78
+
79
+ The conversion inherits the upstream license: **Apache-2.0**.
80
+
81
+ ## Credits
82
+
83
+ - Upstream authors: [ChaoningZhang/MobileSAM](https://github.com/ChaoningZhang/MobileSAM), 2023
84
+ - Core ML conversion: john-rocky (Daisuke Majima)