sightloom-host
Host model package for SightLoom.
SightLoom ranks and remembers. This crate owns:
photo / frame → detect / embed (reference or ONNX) → SightLoom IndexSession
Features
| Feature | What |
|---|---|
std (default) |
Config, preprocess, reference models, HostPipeline |
onnx |
Real ONNX via pure-Rust tract (OnnxEmbedder, OnnxDetector) |
download |
HttpModelFetcher — GET ModelSpec.uri (http/https) into the cache |
image-decode |
JPEG/PNG → RGB for encoded PhotoViews |
full |
onnx + download + image-decode |
Weights stay on the host under .sightloom-models/ (gitignored).
SightLoom never vendors .onnx. Model license and export policy are the
host’s. Recommended pair: YOLOv8n (person detect) + OSNet x1.0
(512-d re-id). With default features nothing is downloaded. Enable download
only for trusted config URIs.
Install
[]
= "0.1" # crates.io line 0.1.7+
# optional:
# sightloom-host = { version = "0.1", features = ["onnx"] }
# sightloom-host = { version = "0.1", features = ["download", "image-decode"] }
# sightloom-host = { version = "0.1", features = ["full"] }
Quick start (reference models — no weights)
Weights cookbook (manifest + integrity)
Scaffold a host-side model inventory (no networks are downloaded by default):
Writes:
models.manifest.json— [ModelManifest] inventory (uri/local_path/ optionalsha256).sightloom-models/README.txt— cache layout noteshost_bundle.example.json— mapped [HostBundleConfig]
Full guide: COOKBOOK.md.
use ;
let manifest = load_path?;
let resolved = resolve_manifest?;
// With feature `download`: HttpModelFetcher pulls ModelSpec.uri when missing.
Optional ModelSpec.sha256 (64-char hex) is checked after every resolve/download
(HostError::Integrity on mismatch).
Step 2: ONNX weights
- Create cache (optional helper):
use write_cache_readme;
write_cache_readme?;
- Place a float32 ONNX file, e.g.:
.sightloom-models/person_reid.onnx
Embedder contract
- Input: NCHW RGB
f32(seePreprocessConfig, default ImageNet mean/std) - Output: embedding vector
f32(L2-normalized byOnnxEmbedder)
Detector contract
- Input: NCHW RGB
f32— usePreprocessConfig::yolo_detect(640, 640)(/255, no ImageNet mean/std, letterbox) - Output (any of):
- YOLOv8 / v11:
[1, 4+C, N](no objectness) - YOLOv5:
[1, N, 5+C](objectness × class) - already-decoded
N×6(x1,y1,x2,y2,score,class)
- YOLOv8 / v11:
- Postprocess: letterbox invert + class-aware hard NMS
- Run:
If weights are missing the example exits with code 2 and prints setup help (CI-friendly).
Host API (HostPipeline, ONNX when present):
let mut pipe = from_onnx_cache?;
let sid = pipe.enroll_photo?; // JPEG/PNG, needs image-decode
let hits = pipe.search_photo_jpeg?;
let tracked = pipe.ingest_frame?;
pipe.save_package?;
use ;
use Path;
let mut spec = embedder;
spec.local_path = Some;
spec.preprocess = imagenet_like;
let embedder = load?;
Step 5: download + encoded photos
HTTP fetch (feature download):
use ;
use Path;
let mut spec = embedder;
spec.uri = Some;
let mut fetcher = default;
let path = fetcher.ensure_local?;
// Local cache hit skips the network on subsequent runs.
JPEG/PNG encoded photos (feature image-decode):
use ;
// PhotoView { encoded: Some(jpeg_or_png_bytes), frame: None, ... }
let rgb = decode_photo_rgb?;
// ReferenceEmbedder / OnnxEmbedder call this path automatically.
Without image-decode, provide PhotoView::frame (raw RGB) or accept the
reference embedder’s raw-byte fingerprint fallback (not for production re-id).
Why tract, not Microsoft ORT?
ort prebuilts are missing on some targets (e.g. x86_64-pc-windows-gnu).
tract-onnx is pure Rust, portable, and enough for step-2 host integration.
Hosts that want CUDA ORT can still implement PhotoEmbeddingAdapter themselves.
Step 3: evidence packs
Writes MOT smoke + MOTChallenge export, re-id ROC/EER, and redaction pixel reports. See evidence/README.md.
use ByteTrackConfig;
use ;
let pack = build_synthetic_evidence_pack.unwrap;
assert!;
write_evidence_pack.unwrap;
Honest boundary
| Path | Accuracy claim |
|---|---|
| Reference embedders | wiring only |
| Your ONNX weights + tract | depends on your model |
| Synthetic evidence pack | harness smoke only — not MOT17 / production re-id |
Docs
docs.rs/sightloom-host (after publish)