File size: 1,722 Bytes
c3d9cdc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
license: apache-2.0
base_model: yunyangx/EfficientSAM
pipeline_tag: mask-generation
library_name: coreai
tags:
  - coreai
  - ios
  - image-segmentation
  - react-native
---

# EfficientSAM-Ti for Core AI

[EfficientSAM](https://github.com/yformer/EfficientSAM) ViT-Tiny (10M parameters) exported to Apple Core AI, unmodified, with the [`apple/coreai-models`](https://github.com/apple/coreai-models) recipe. It runs on iOS 27 and macOS 27 with the `ImageSegmenter` from the `CoreAISegmentation` product of `coreai-models`.

It segments the object at a point (a click) or in a box, one mask per prompt.

## Files

`efficient-sam/` is a segmenter bundle: `metadata.json` and the exported model, float32, static shape, up to two points per prompt (39 MB).

## Use

With [`@react-native-ai/core-ai`](https://github.com/callstackincubator/ai), download the folder and pass its path:

```typescript
import { CoreAI } from '@react-native-ai/core-ai'

const result = await CoreAI.runTask(
  'segmentation',
  { id: 'efficient-sam', sourceType: 'file', sourceUri: efficientSAMBundlePath },
  { imageUri, data: { box: { x: 10, y: 50, width: 300, height: 400 } } },
  {}
)
```

In Swift:

```swift
let segmenter = try await ImageSegmenter(resourcesAt: "efficient-sam")
let response = try await segmenter.segment(image: cgImage, pointQuery: query)
```

## Export

From [`apple/coreai-models`](https://github.com/apple/coreai-models) at `09ff139`, with `coreai-core` 1.0.0b3:

```bash
cd models/efficient-sam
uv run export.py
```

## License

Apache-2.0, as the original model. EfficientSAM is by Y. Xiong et al., [EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment Anything](https://arxiv.org/abs/2312.00863).