model card: samples, charts, edge only
Browse files
README.md
CHANGED
|
@@ -19,31 +19,59 @@ tags:
|
|
| 19 |
|
| 20 |
# sam3-edge
|
| 21 |
|
| 22 |
-
SAM 3's text-prompted detector, slimmed to run on boards without a GPU: a Rubik Pi 3 (Qualcomm QCS6490)
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
These are the exported files for the code at [github.com/eoinjordan/sam3-edge](https://github.com/eoinjordan/sam3-edge).
|
| 27 |
Nothing here was trained by this project: the weights are SAM 3's, and its distilled encoders from
|
| 28 |
[EfficientSAM3](https://github.com/SimonZeng7108/efficientsam3), converted to ONNX graphs, quantised and repackaged.
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
| `onnx/sam3-litetext-r336-g24-*`, `-r672-g48-*`, `sam3-litetext-light.pt` | quality tier: SAM 3's own image encoder with 8-bit weights, at 336 px and 672 px | the full tool |
|
| 36 |
-
| `micro/sam3micro-fast-672`, `micro/sam3micro-fast-1008` | the fast tier as bundles that run without PyTorch, with NPU graphs | `python -m sam3micro` |
|
| 37 |
-
| `micro/sam3micro-quality-336` | the quality tier at 336 px as a bundle that runs without PyTorch | `python -m sam3micro` |
|
| 38 |
-
| `micro/sam3micro` | the sam3micro runtime itself: three small Python files (numpy, Pillow, ONNX Runtime) | copy beside the bundles |
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
site terms.
|
| 43 |
|
| 44 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
```sh
|
| 49 |
git clone https://github.com/eoinjordan/sam3-edge && cd sam3-edge
|
|
@@ -53,41 +81,84 @@ python -m sam3.edge fetch-graphs --variant sam3-litetext --resolution 336 --int8
|
|
| 53 |
python -m sam3.edge detect frame.jpg --concept "red bus" --variant sam3-litetext --resolution 336 --int8 --masks --out out.jpg
|
| 54 |
```
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
pip install onnxruntime numpy pillow huggingface_hub
|
| 60 |
-
hf download eoinedge/sam3-edge --include "micro/sam3micro/*" --include "micro/sam3micro-fast-672/*" --local-dir .
|
| 61 |
-
cd micro && python -m sam3micro detect sam3micro-fast-672 frame.jpg --concept bus
|
| 62 |
-
```
|
| 63 |
|
| 64 |
-
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
image; each further concept on the same image costs the detector pass only.
|
| 68 |
|
| 69 |
-
| Configuration | Image pass | Detector pass |
|
| 70 |
|---|---|---|---|---|
|
| 71 |
-
|
|
| 72 |
-
|
|
| 73 |
-
| Fast tier,
|
| 74 |
-
|
|
| 75 |
-
|
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
On EfficientSAM3's own example image the three published students return the dog as a second "person"; the quality
|
| 82 |
-
tier returns the person alone. The full comparison is in the repository's `docs/comparison.md`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
## Limits
|
| 85 |
|
| 86 |
- The quality tier at 336 px loses small objects. Match the input size to the camera; 336 px suits low-resolution
|
| 87 |
feeds, 672 px needs about 2.3 GB of memory.
|
| 88 |
- The fast tier is weaker than SAM 3: lower scores, wrong labels on small or low-resolution scenes.
|
| 89 |
-
-
|
| 90 |
-
- Image-only
|
|
|
|
|
|
|
| 91 |
- Detections are advisory. Do not use them alone for safety, identification or enforcement decisions.
|
| 92 |
|
| 93 |
## Licence and provenance
|
|
@@ -95,5 +166,6 @@ tier returns the person alone. The full comparison is in the repository's `docs/
|
|
| 95 |
Everything here derives from SAM 3 and is distributed under the **SAM License** (`LICENSE`), which requires this
|
| 96 |
licence to travel with any redistribution and forbids several uses, including military and weapons applications.
|
| 97 |
The distilled encoders come from EfficientSAM3 (Apache-2.0 per its model card); the MobileCLIP text encoder they are
|
| 98 |
-
distilled into carries Apple's terms. `NOTICE.edge.md`
|
| 99 |
-
|
|
|
|
|
|
| 19 |
|
| 20 |
# sam3-edge
|
| 21 |
|
| 22 |
+
SAM 3's text-prompted detector, slimmed to run on boards without a GPU: a Rubik Pi 3 (Qualcomm QCS6490) or a
|
| 23 |
+
QCS8300 board. You give it an image and a short noun phrase ("red bus", "person wearing a helmet"); it returns a
|
| 24 |
+
box, a score and a mask for every instance. Any phrase works: the text encoder is on the board.
|
| 25 |
|
| 26 |
These are the exported files for the code at [github.com/eoinjordan/sam3-edge](https://github.com/eoinjordan/sam3-edge).
|
| 27 |
Nothing here was trained by this project: the weights are SAM 3's, and its distilled encoders from
|
| 28 |
[EfficientSAM3](https://github.com/SimonZeng7108/efficientsam3), converted to ONNX graphs, quantised and repackaged.
|
| 29 |
|
| 30 |
+
There are two tiers:
|
| 31 |
|
| 32 |
+
- **Quality tier** (`sam3-litetext`): SAM 3's own image encoder with 8-bit weights, at 336 px or 672 px.
|
| 33 |
+
- **Fast tier** (`efficientvit-m`): a distilled EfficientViT-B1 image encoder at 1008 px on a 36 x 36 token grid.
|
| 34 |
+
Its image encoder also runs on the Hexagon NPU.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
For 4 GB boards there is a separate, more restricted model with no PyTorch, a fixed concept list and boxes only:
|
| 37 |
+
[eoinedge/sam3micro](https://huggingface.co/eoinedge/sam3micro).
|
|
|
|
| 38 |
|
| 39 |
+
## Samples
|
| 40 |
+
|
| 41 |
+
Every picture below is what the files in this repository returned when `tools/card_samples.py` ran them
|
| 42 |
+
(2026-11-19, laptop CPU, ONNX Runtime). Nothing is hand-edited.
|
| 43 |
+
|
| 44 |
+
**Both tiers on the SAM 3 test images.** The fast tier misses the truck and is unsure about the bags; the quality
|
| 45 |
+
tier finds the truck and all four bags at either size.
|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
|
| 49 |
+
**A 352 x 288 traffic-camera frame.** On low-resolution street footage the fast tier fails: it finds no bus and
|
| 50 |
+
labels one as a person. The quality tier finds both buses.
|
| 51 |
+
|
| 52 |
+

|
| 53 |
+
|
| 54 |
+
**A clip at night, one frame at a time.** The quality tier answering "bus", "car" and "person" on every second
|
| 55 |
+
frame of a ten-second traffic-camera clip, 2.3 s a frame on a laptop CPU. There is no tracker: each frame is
|
| 56 |
+
answered on its own, so detections flicker, and in the dark it misses some vehicles that are plain to the eye.
|
| 57 |
|
| 58 |
+

|
| 59 |
+
|
| 60 |
+
The same clip as video: [assets/sample-clip.mp4](assets/sample-clip.mp4).
|
| 61 |
+
|
| 62 |
+
Street frame and clip: Powered by TfL Open Data.
|
| 63 |
+
|
| 64 |
+
## What is in this repository
|
| 65 |
+
|
| 66 |
+
| Files | What |
|
| 67 |
+
|---|---|
|
| 68 |
+
| `onnx/sam3-litetext-r336-g24-*`, `onnx/sam3-litetext-r672-g48-*` | quality tier graphs at 336 px and 672 px (image encoder in 8-bit weights, detector in float) |
|
| 69 |
+
| `onnx/sam3-litetext-light.pt` | the weights PyTorch still uses for the quality tier: text encoder, prompt encoder, mask head |
|
| 70 |
+
| `onnx/efficientvit-m-r1008-g36-*` | fast tier graphs: float image encoder, a fixed-point one for the Hexagon NPU, detector |
|
| 71 |
+
| `onnx/efficientvit-m-light.pt` | the weights PyTorch still uses for the fast tier |
|
| 72 |
+
| `assets/` | the pictures and charts on this page |
|
| 73 |
+
|
| 74 |
+
## Use
|
| 75 |
|
| 76 |
```sh
|
| 77 |
git clone https://github.com/eoinjordan/sam3-edge && cd sam3-edge
|
|
|
|
| 81 |
python -m sam3.edge detect frame.jpg --concept "red bus" --variant sam3-litetext --resolution 336 --int8 --masks --out out.jpg
|
| 82 |
```
|
| 83 |
|
| 84 |
+
For the fast tier: `fetch-graphs --variant efficientvit-m`, then `detect ... --variant efficientvit-m`, with `--npu`
|
| 85 |
+
on a board with a Hexagon NPU and the `onnxruntime-qnn` package. `python -m sam3.edge serve` answers the same
|
| 86 |
+
requests over HTTP. These commands were run from an empty folder against this repository on 2026-11-19.
|
| 87 |
|
| 88 |
+
## Speed
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
Rubik Pi 3, four Cortex-A78 cores, on-device vision services paused. The first row is EfficientSAM3's EV-M run the
|
| 91 |
+
way it is published (PyTorch, SAM 3's 72 x 72 token grid, the mask head on every call); the fast tier is the same
|
| 92 |
+
weights.
|
| 93 |
|
| 94 |
+

|
|
|
|
| 95 |
|
| 96 |
+
| Configuration | Image pass | Detector pass | Mask head | First concept |
|
| 97 |
|---|---|---|---|---|
|
| 98 |
+
| EfficientSAM3 EV-M as published | 2.33 s | 6.90 s | 9.12 s | 18.4 s |
|
| 99 |
+
| Quality tier, 336 px | 3.07 s | 0.42 s | on request | 3.50 s |
|
| 100 |
+
| Fast tier, 1008 px / 36 grid | 0.99 s | 0.88 s | on request | 1.86 s |
|
| 101 |
+
| Fast tier, 1008 px, image encoder on the NPU | 0.20 s | 0.89 s | on request | 1.09 s |
|
| 102 |
+
| Fast tier, 672 px / 24 grid | 0.43 s | 0.45 s | on request | 0.89 s |
|
| 103 |
+
|
| 104 |
+
Each further concept on the same image costs the detector pass only. Masks add 2.3 s at the 36 grid.
|
| 105 |
+
|
| 106 |
+
## Hexagon NPU
|
| 107 |
+
|
| 108 |
+
The fast tier's image encoder runs on the QCS6490's Hexagon NPU through ONNX Runtime's QNN provider, about five
|
| 109 |
+
times faster than on the CPU. The NPU takes fixed-point graphs only, and which layout survives was measured:
|
| 110 |
+
|
| 111 |
+

|
| 112 |
+
|
| 113 |
+

|
| 114 |
+
|
| 115 |
+
| Activations | Weights | Similarity to float | |
|
| 116 |
+
|---|---|---|---|
|
| 117 |
+
| 8-bit | 8-bit | 0.25 to 0.36 | detections vanish |
|
| 118 |
+
| 16-bit | 8-bit per tensor | 0.67 to 0.80 | |
|
| 119 |
+
| 16-bit | 8-bit per channel | 0.997 to 0.999 | what `--npu` exports |
|
| 120 |
+
| 16-bit | 16-bit | 0.9994 to 0.9996 | refused by this chip's NPU |
|
| 121 |
+
|
| 122 |
+
On the NPU itself the similarity is 0.983 on ordinary photos, and accuracy on a COCO sample was unchanged (F1 0.30
|
| 123 |
+
against 0.29 in float, measured at 672 px). The quality tier's encoder is not on the NPU.
|
| 124 |
+
|
| 125 |
+
## Accuracy
|
| 126 |
|
| 127 |
+
A seeded 60-image COCO val2017 sample, IoU 0.5: a relative check between settings, not a benchmark.
|
| 128 |
+
|
| 129 |
+

|
| 130 |
+
|
| 131 |
+
| Setting | F1 at threshold 0.5 | F1 at threshold 0.3 |
|
| 132 |
+
|---|---|---|
|
| 133 |
+
| Quality tier, 672 px | 0.70 | 0.61 |
|
| 134 |
+
| Quality tier, 336 px | 0.41 | 0.30 |
|
| 135 |
+
| Fast tier weights at SAM 3's 72 grid | 0.41 | 0.49 |
|
| 136 |
+
| Fast tier, 36 grid | 0.39 | 0.42 |
|
| 137 |
|
| 138 |
On EfficientSAM3's own example image the three published students return the dog as a second "person"; the quality
|
| 139 |
+
tier returns the person alone. The full comparison is in the code repository's `docs/comparison.md`.
|
| 140 |
+
|
| 141 |
+
## Memory
|
| 142 |
+
|
| 143 |
+

|
| 144 |
+
|
| 145 |
+
| Setting | Memory | Files on the board |
|
| 146 |
+
|---|---|---|
|
| 147 |
+
| Quality tier, 336 px | 1.3 GB | 545 MB graphs, 333 MB light weights |
|
| 148 |
+
| Fast tier, 1008 px | 1.1 GB | 150 MB graphs, 333 MB light weights |
|
| 149 |
+
|
| 150 |
+
The quality tier at 672 px needs about 2.3 GB. The chart's sam3micro bars are the separate
|
| 151 |
+
[sam3micro](https://huggingface.co/eoinedge/sam3micro) model.
|
| 152 |
|
| 153 |
## Limits
|
| 154 |
|
| 155 |
- The quality tier at 336 px loses small objects. Match the input size to the camera; 336 px suits low-resolution
|
| 156 |
feeds, 672 px needs about 2.3 GB of memory.
|
| 157 |
- The fast tier is weaker than SAM 3: lower scores, wrong labels on small or low-resolution scenes.
|
| 158 |
+
- At night on a low-resolution feed even the quality tier misses vehicles (see the clip).
|
| 159 |
+
- Image-only. Video is per frame, with no tracker: SAM 3's video mode is a separate memory-based tracker that this
|
| 160 |
+
build leaves out.
|
| 161 |
+
- Not measured on a QCS8300 board.
|
| 162 |
- Detections are advisory. Do not use them alone for safety, identification or enforcement decisions.
|
| 163 |
|
| 164 |
## Licence and provenance
|
|
|
|
| 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 they are
|
| 169 |
+
distilled into carries Apple's terms. `NOTICE.edge.md` lists each part. The test images in the samples are SAM 3's;
|
| 170 |
+
the street frame and clip are 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.
|