Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: coreml
|
| 4 |
+
pipeline_tag: zero-shot-image-classification
|
| 5 |
+
base_model: google/siglip-base-patch16-224
|
| 6 |
+
base_model_relation: quantized
|
| 7 |
+
tags:
|
| 8 |
+
- coreml
|
| 9 |
+
- core-ml
|
| 10 |
+
- ios
|
| 11 |
+
- macos
|
| 12 |
+
- apple
|
| 13 |
+
- on-device
|
| 14 |
+
- siglip
|
| 15 |
+
- clip
|
| 16 |
+
- zero-shot
|
| 17 |
+
- image-text
|
| 18 |
+
- arxiv:2303.15343
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# SigLIP — Core ML
|
| 22 |
+
|
| 23 |
+
*Zero-Shot Classification, 2023*
|
| 24 |
+
|
| 25 |
+
Zero-shot image classification. Dual encoder (image + text). 224×224 input.
|
| 26 |
+
|
| 27 |
+
Core ML conversion of [google-research/big_vision](https://github.com/google-research/big_vision) 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.
|
| 28 |
+
|
| 29 |
+
| | |
|
| 30 |
+
|---|---|
|
| 31 |
+
| Task | zero shot image classification |
|
| 32 |
+
| Upstream | [google-research/big_vision](https://github.com/google-research/big_vision) |
|
| 33 |
+
| Packages | 2 |
|
| 34 |
+
| Download size | 358 MB |
|
| 35 |
+
| Minimum iOS | 17.0 |
|
| 36 |
+
| Peak RAM | ~800 MB |
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
| File | Size | Compute units | SHA-256 |
|
| 41 |
+
|---|---:|---|---|
|
| 42 |
+
| `SigLIP_ImageEncoder.mlpackage.zip` | 162 MB | `cpuOnly` | `98f6abf5f4aa1451…` |
|
| 43 |
+
| `SigLIP_TextEncoder.mlpackage.zip` | 195 MB | `cpuOnly` | `9dead2d58705838a…` |
|
| 44 |
+
| `siglip_vocab.json` | 658 KB | `-` | `b94b3a58e04f6199…` |
|
| 45 |
+
| **Total** | **358 MB** | | |
|
| 46 |
+
|
| 47 |
+
`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.
|
| 48 |
+
|
| 49 |
+
## Download
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
hf download mlboydaisuke/coreml-zoo --include "siglip/*" --local-dir ./siglip
|
| 53 |
+
unzip './siglip/siglip/*.zip' -d ./siglip
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## Use in Swift
|
| 57 |
+
|
| 58 |
+
```swift
|
| 59 |
+
import CoreML
|
| 60 |
+
|
| 61 |
+
let config = MLModelConfiguration()
|
| 62 |
+
config.computeUnits = .cpuOnly // as converted — see the table above
|
| 63 |
+
|
| 64 |
+
// Unzip the .mlpackage, drop it into your Xcode target and Xcode compiles it
|
| 65 |
+
// at build time:
|
| 66 |
+
let model = try SigLIP_ImageEncoder(configuration: config)
|
| 67 |
+
|
| 68 |
+
// ...or compile a downloaded .mlpackage at runtime:
|
| 69 |
+
let compiled = try await MLModel.compileModel(at: mlpackageURL)
|
| 70 |
+
let model = try MLModel(contentsOf: compiled, configuration: config)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
> This model is split into 2 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.
|
| 74 |
+
|
| 75 |
+
## Demo
|
| 76 |
+
|
| 77 |
+
- **Sample app** — [`sample_apps/SigLIPDemo`](https://github.com/john-rocky/CoreML-Models/tree/master/sample_apps/SigLIPDemo), a standalone SwiftUI project.
|
| 78 |
+
- **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.
|
| 79 |
+
|
| 80 |
+
## Conversion
|
| 81 |
+
|
| 82 |
+
- Script: [`convert_siglip.py`](https://github.com/john-rocky/CoreML-Models/blob/master/conversion_scripts/convert_siglip.py)
|
| 83 |
+
- 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)
|
| 84 |
+
- Model index: [CoreML-Models](https://github.com/john-rocky/CoreML-Models)
|
| 85 |
+
|
| 86 |
+
## License
|
| 87 |
+
|
| 88 |
+
The conversion inherits the upstream license: **Apache-2.0**.
|
| 89 |
+
|
| 90 |
+
## Credits
|
| 91 |
+
|
| 92 |
+
- Upstream authors: [google-research/big_vision](https://github.com/google-research/big_vision), 2023
|
| 93 |
+
- Core ML conversion: john-rocky (Daisuke Majima)
|