lightcraft/crates
Guinther Kovalski 6468bfc06b M12: SAM 3 Object and Describe masks (pure Rust, Metal)
AI masks from Meta's SAM 3, run in LightCraft itself: a new
`lightcraft-segment` crate ports the Hugging Face transformers
implementation (Apache-2.0) to candle, on the GPU through Metal on macOS
(CPU elsewhere), with no C/C++ and no `unsafe`.

- Object: click to include, ⌥-click to leave a part out (SAM 3's
  interactive prompt encoder + two-way mask decoder).
- Describe: a text prompt selects every instance ("sky", "the red car";
  "car, road" merges several) via the CLIP text encoder and DETR detector.
- Both as new masks and as Add / Subtract / Intersect components; + / −
  buttons under the selected mask combine selections.
- The segmentation is stored with the mask (288² quantized logits, ~10-30
  KB), so renders, exports and the web build never need the model.
- A zoomed-in detail pass (background, ~5 s on an M4 Pro) re-segments the
  area around a selection from a sharper source: 5-10x finer edges on
  small objects.
- Per-selection Edge slider (hard ↔ soft); hovering a mask in the list
  shows it in red (the always-on overlay is now off by default, O toggles).
- The engine feature `sam` (on in the desktop app) gates the model; the
  image is encoded once per photo in the background, clicks take ~35 ms.
- Weights are not bundled (SAM License): tools/install-sam3.sh / .ps1
  download and verify facebook/sam3; docs/ai-masks.md.
- Clearer errors (missing file, missing model) and a stderr logger in the
  app (LIGHTCRAFT_LOG=info).

candle is pinned at 0.9.2: later releases make candle-core depend on
tokenizers with the Oniguruma C library. Every stage is checked against
the Python reference (tests/reference.rs, tools/sam3_reference.py): on
Metal the backbone matches to 7e-5 relative error, masks to ~5e-5.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C8BkS7JDqa1EMcjW6spDGA
2026-10-06 20:15:04 -03:00
..
catalog Issue #134: Exports: atomic without fsync; Copy import verifies against the probe hash 2026-10-06 10:08:29 -04:00
codecs Merge pull request #54 from storytold/pr/never-crash-codecs-catalog 2026-10-04 14:23:05 -04:00
color Never crash: color, geom, raster, develop, scenes, preview, pipeline 2026-10-04 12:34:53 -04:00
develop M12: SAM 3 Object and Describe masks (pure Rust, Metal) 2026-10-06 20:15:04 -03:00
engine M12: SAM 3 Object and Describe masks (pure Rust, Metal) 2026-10-06 20:15:04 -03:00
geom Never crash: color, geom, raster, develop, scenes, preview, pipeline 2026-10-04 12:34:53 -04:00
gpu Issue #136: Windows: use DX12 by default, honour WGPU_BACKEND, never let GPU init block startup 2026-10-06 10:16:05 -04:00
mcp Merge main into fix/issue-93-export-overwrite 2026-10-05 18:44:02 -04:00
merge Issue #138: DNG: apply the file's own camera-profile look (HueSatMap, LookTable, ToneCurve) 2026-10-06 10:36:30 -04:00
meta Issue #92: XMP: merge into an existing sidecar instead of replacing it 2026-10-05 17:08:18 -04:00
pipeline M12: SAM 3 Object and Describe masks (pure Rust, Metal) 2026-10-06 20:15:04 -03:00
preview Issue #98: thumbnail cache only lists, counts and deletes its own files 2026-10-05 16:23:32 -04:00
raster Merge pull request #56 from storytold/pr/never-crash-core 2026-10-04 14:23:22 -04:00
raw Issue #148: Raw: read white balance, black level and crop of pre-2017 Sony ARWs 2026-10-06 15:27:33 -04:00
scenes Never crash: color, geom, raster, develop, scenes, preview, pipeline 2026-10-04 12:34:53 -04:00
segment M12: SAM 3 Object and Describe masks (pure Rust, Metal) 2026-10-06 20:15:04 -03:00
sysmem Never crash: move the one unsafe FFI call into crates/sysmem 2026-10-05 02:06:08 -04:00
tiff Issue #138: DNG: apply the file's own camera-profile look (HueSatMap, LookTable, ToneCurve) 2026-10-06 10:36:30 -04:00
ui-egui M12: SAM 3 Object and Describe masks (pure Rust, Metal) 2026-10-06 20:15:04 -03:00