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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: sam-license
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model:
|
| 6 |
+
- facebook/sam3
|
| 7 |
+
library_name: onnx
|
| 8 |
+
pipeline_tag: object-detection
|
| 9 |
+
tags:
|
| 10 |
+
- sam3
|
| 11 |
+
- segment-anything
|
| 12 |
+
- edge
|
| 13 |
+
- onnx
|
| 14 |
+
- onnxruntime
|
| 15 |
+
- microcontroller-class
|
| 16 |
+
- qualcomm
|
| 17 |
+
- hexagon-npu
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# sam3micro
|
| 21 |
+
|
| 22 |
+
SAM 3's text-prompted detector cut down for 4 GB boards. It runs with **no PyTorch**: numpy, Pillow and ONNX
|
| 23 |
+
Runtime, three small Python files and a bundle of two graphs. You give it an image and a concept from its list
|
| 24 |
+
("bus", "person", "forklift"); it returns a box and a score for every instance.
|
| 25 |
+
|
| 26 |
+
It is restricted on purpose:
|
| 27 |
+
|
| 28 |
+
- **A fixed concept list.** The text encoder stays on the PC that exports the bundle. These bundles hold 104
|
| 29 |
+
concepts: the 80 COCO categories and some street and site terms (`micro.json` lists them).
|
| 30 |
+
- **Boxes only.** No masks.
|
| 31 |
+
- **One image at a time**, no video tracking.
|
| 32 |
+
|
| 33 |
+
For free-text concepts and masks on a larger board, use the full model:
|
| 34 |
+
[eoinedge/sam3-edge](https://huggingface.co/eoinedge/sam3-edge). Nothing here was trained by this project: the
|
| 35 |
+
weights are SAM 3's and its distilled encoders from [EfficientSAM3](https://github.com/SimonZeng7108/efficientsam3),
|
| 36 |
+
converted and repackaged by [github.com/eoinjordan/sam3-edge](https://github.com/eoinjordan/sam3-edge).
|
| 37 |
+
|
| 38 |
+
## Bundles
|
| 39 |
+
|
| 40 |
+
| Bundle | Image encoder | Size | Memory | Best for |
|
| 41 |
+
|---|---|---|---|---|
|
| 42 |
+
| `bundles/fast-672` | distilled EfficientViT-B1, 672 px, 24 x 24 tokens | 182 MB | 0.44 GB | the smallest boards; large, clear objects |
|
| 43 |
+
| `bundles/fast-1008` | the same encoder, 1008 px, 36 x 36 tokens | 182 MB | 0.57 GB | more detail, about twice the time |
|
| 44 |
+
| `bundles/quality-336` | SAM 3's own image encoder, 8-bit weights, 336 px | 543 MB | 0.82 GB | low-resolution feeds and judgement over speed |
|
| 45 |
+
|
| 46 |
+
The two fast bundles also carry a fixed-point image graph for boards with a Hexagon NPU (`--npu`).
|
| 47 |
+
|
| 48 |
+
## Samples
|
| 49 |
+
|
| 50 |
+
Each picture is what the bundle returned through the sam3micro runtime (2026-11-19, laptop CPU). Nothing is
|
| 51 |
+
hand-edited.
|
| 52 |
+
|
| 53 |
+
**Fast bundle on a clear photo.** People and shoes, boxes only.
|
| 54 |
+
|
| 55 |
+

|
| 56 |
+
|
| 57 |
+
**Quality bundle on a 352 x 288 traffic-camera frame.** Both buses and two cars.
|
| 58 |
+
|
| 59 |
+

|
| 60 |
+
|
| 61 |
+
**Fast bundle on the same frame.** This is its weak spot: on low-resolution street footage it finds no bus and
|
| 62 |
+
labels one as a person.
|
| 63 |
+
|
| 64 |
+

|
| 65 |
+
|
| 66 |
+
Street frame: Powered by TfL Open Data.
|
| 67 |
+
|
| 68 |
+
## Use
|
| 69 |
+
|
| 70 |
+
```sh
|
| 71 |
+
pip install onnxruntime numpy pillow huggingface_hub
|
| 72 |
+
hf download eoinedge/sam3micro --include "sam3micro/*" --include "bundles/fast-672/*" --local-dir sam3micro-kit
|
| 73 |
+
cd sam3micro-kit
|
| 74 |
+
python -m sam3micro detect bundles/fast-672 frame.jpg --concept bus --concept person
|
| 75 |
+
python -m sam3micro bench bundles/fast-672 frame.jpg --concept bus
|
| 76 |
+
python -m sam3micro info bundles/fast-672 # the concept list and the memory it needs
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
```python
|
| 80 |
+
from PIL import Image
|
| 81 |
+
from sam3micro import Micro
|
| 82 |
+
|
| 83 |
+
micro = Micro("bundles/fast-672")
|
| 84 |
+
for det in micro.detect(Image.open("frame.jpg"), ["bus", "person"]):
|
| 85 |
+
print(det["concept"], det["score"], det["box_xyxy"])
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
It refuses to load when the board has less free memory than the bundle needs (`--force` overrides): on a board with
|
| 89 |
+
no swap, running short stalls everything on it. On a board with a Hexagon NPU, `pip install onnxruntime-qnn` and add
|
| 90 |
+
`--npu`. To change the concept list or the input size, export your own bundle with
|
| 91 |
+
`python -m sam3.edge export-micro` from the code repository.
|
| 92 |
+
|
| 93 |
+
## Speed
|
| 94 |
+
|
| 95 |
+

|
| 96 |
+
|
| 97 |
+
Rubik Pi 3 (Qualcomm QCS6490), on-device vision services paused. "Four small cores" is the board's four
|
| 98 |
+
Cortex-A55 cores under a 900 MB memory cap.
|
| 99 |
+
|
| 100 |
+
| Bundle | Where | Image pass | Detector pass | First concept |
|
| 101 |
+
|---|---|---|---|---|
|
| 102 |
+
| fast-672 | four Cortex-A78 cores | 0.47 s | 0.40 s | 0.87 s |
|
| 103 |
+
| fast-672 | image encoder on the Hexagon NPU | 0.085 s | 0.45 s | 0.53 s |
|
| 104 |
+
| fast-672 | four small cores | 1.26 s | 1.23 s | 2.49 s |
|
| 105 |
+
| fast-1008 | four Cortex-A78 cores | 1.05 s | 0.93 s | 1.98 s |
|
| 106 |
+
| fast-1008 | image encoder on the Hexagon NPU | 0.20 s | 0.89 s | 1.09 s |
|
| 107 |
+
| fast-1008 | four small cores | 2.76 s | 2.58 s | 5.34 s |
|
| 108 |
+
| quality-336 | four Cortex-A78 cores | 3.51 s | 0.44 s | 3.95 s |
|
| 109 |
+
| quality-336 | four small cores | 9.72 s | 1.21 s | 10.9 s |
|
| 110 |
+
|
| 111 |
+
Each further concept on the same image costs the detector pass only.
|
| 112 |
+
|
| 113 |
+
**The small-core rows are a stand-in for an Arduino UNO Q, not a measurement of one.** The UNO Q's Cortex-A53
|
| 114 |
+
cores are slower than Cortex-A55 and lack the dot-product instructions the quality bundle's 8-bit encoder uses, so
|
| 115 |
+
expect it to be slower there than these rows, the quality bundle most of all. It has not been run on a UNO Q.
|
| 116 |
+
|
| 117 |
+
## Accuracy
|
| 118 |
+
|
| 119 |
+
A seeded 60-image COCO val2017 sample, IoU 0.5: a relative check between settings, not a benchmark.
|
| 120 |
+
|
| 121 |
+

|
| 122 |
+
|
| 123 |
+
| Bundle | F1 at threshold 0.5 | F1 at threshold 0.3 |
|
| 124 |
+
|---|---|---|
|
| 125 |
+
| fast-1008 | 0.39 | 0.42 |
|
| 126 |
+
| quality-336 | 0.41 | 0.30 |
|
| 127 |
+
| fast-672 | 0.24 | 0.29 |
|
| 128 |
+
| a 448 px / 16 grid export, not shipped | 0.11 | 0.18 |
|
| 129 |
+
|
| 130 |
+
For scale, the full quality tier at 672 px scores 0.70 on the same sample. A bundle answers exactly as the full
|
| 131 |
+
tool does at the same setting (score differences up to 0.001), and with the image encoder on the NPU the fast-672
|
| 132 |
+
figure is unchanged (0.30 against 0.29).
|
| 133 |
+
|
| 134 |
+
## Memory
|
| 135 |
+
|
| 136 |
+

|
| 137 |
+
|
| 138 |
+
| Bundle | Peak memory | Files |
|
| 139 |
+
|---|---|---|
|
| 140 |
+
| fast-672 | 0.44 GB | 182 MB |
|
| 141 |
+
| fast-1008 | 0.57 GB | 182 MB |
|
| 142 |
+
| quality-336 | 0.82 GB | 543 MB |
|
| 143 |
+
|
| 144 |
+
## Hexagon NPU
|
| 145 |
+
|
| 146 |
+
The fast bundles' image encoder runs on a QCS6490's NPU about five times faster than on its CPU. The NPU takes
|
| 147 |
+
fixed-point graphs only; the layout that keeps the features is 16-bit activations with 8-bit per-channel weights.
|
| 148 |
+
|
| 149 |
+

|
| 150 |
+
|
| 151 |
+

|
| 152 |
+
|
| 153 |
+
The first load compiles the graph for the NPU (about 25 s) and caches it beside the bundle.
|
| 154 |
+
|
| 155 |
+
## Limits
|
| 156 |
+
|
| 157 |
+
- The fast bundles are weak on small objects and on low-resolution or dark scenes, and they answer concepts that
|
| 158 |
+
are not in the picture more often than SAM 3 does. Use a threshold near 0.3 and treat results as hints.
|
| 159 |
+
- The quality bundle at 336 px loses small objects and takes four times as long.
|
| 160 |
+
- A fixed concept list, no masks, no tracking.
|
| 161 |
+
- Not measured on an Arduino UNO Q or any Cortex-A53 board.
|
| 162 |
+
- Detections are advisory. Do not use them alone for safety, identification or enforcement decisions.
|
| 163 |
+
|
| 164 |
+
## Licence and provenance
|
| 165 |
+
|
| 166 |
+
Everything here derives from SAM 3 and is distributed under the **SAM License** (`LICENSE`), which requires this
|
| 167 |
+
licence to travel with any redistribution and forbids several uses, including military and weapons applications.
|
| 168 |
+
The distilled encoders come from EfficientSAM3 (Apache-2.0 per its model card); the MobileCLIP text encoder used to
|
| 169 |
+
encode the concept list carries Apple's terms. `NOTICE.edge.md` lists each part. The sample photo is a SAM 3 test
|
| 170 |
+
image; the street frame is Transport for London open data. If you publish work that uses these files, the SAM
|
| 171 |
+
License asks you to acknowledge the use of SAM Materials.
|