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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Local backends on ONNX Runtime through `ort` (spec 3.7 §7.6), features `onnx` and
//! `onnx-dynamic`.
//!
//! | Backend | Trait | Models | Answers in |
//! |---------|-------|--------|------------|
//! | [`RfDetr`] | [`Detector`](crate::Detector) | RF-DETR N, S and M; an RF-DETR-Seg export adds instance masks | `ModelInput` with the manifest's letterbox |
//! | [`EfficientSam`] | [`Segmenter`](crate::Segmenter) | EfficientSAM-Ti (split encoder and decoder) | `SentPixels` |
//! | [`Sam2`] | [`Segmenter`](crate::Segmenter) | SAM 2.1 Tiny (split encoder and decoder) | `ModelInput` 1024×1024, stretched |
//! | [`SigLip2`] | [`Embedder`](crate::Embedder) | SigLIP 2 base (so400m opt-in) | — |
//! | `Sam3`, `Sam3Tracker` (feature `sam3-local`) | [`Segmenter`](crate::Segmenter), [`Detector`](crate::Detector) | SAM 3 from weights you supply under Meta's SAM License, after you accept it | `ModelInput` 1008×1008, stretched |
//! | [`YuNet`] | [`Detector`](crate::Detector) | YuNet 2023mar faces, for the privacy redactors | `SentPixels` |
//!
//! Every backend is built from a [`VerifiedModel`](crate::VerifiedModel), so no file loads
//! unless its SHA-256 matched its manifest (V-I10), and reads its input size, normalisation
//! and labels from the manifest's [`IoSpec`](crate::IoSpec): a user's own export, such as an
//! RF-DETR fine-tune, runs through the same backend with its own manifest. Each backend is
//! on-device ([`Locality::InProcess`](crate::Locality::InProcess)), so the runtime records
//! its units at zero cost and it never touches the egress gate.
//!
//! Inference runs on a blocking thread, so a call does not stall the async runtime and the
//! runtime's cancellation ends the call at once. The SAM-family encoders run once per
//! prepared image and their decoders once per prompt group.
//!
//! [`OnnxOptions`] chooses the execution provider at run time: the CPU by default, CoreML
//! on Apple (feature `onnx-coreml`) and CUDA (feature `onnx-cuda`). A provider this build
//! does not compile, or one that cannot start on this machine, falls back to the CPU with a
//! warning.
//!
//! # Example
//!
//! ```no_run
//! use std::sync::Arc;
//! use adk_vision::onnx::{OnnxOptions, RfDetr};
//! use adk_vision::{
//! DecodeLimits, DetectQuery, FetchConfig, InMemoryAcceptanceStore, ManifestSet,
//! ModelFetcher, SourceImage, VisionCx, VisionRuntime,
//! };
//!
//! # async fn demo() -> adk_vision::Result<()> {
//! let manifests = ManifestSet::builtin()?;
//! let fetcher =
//! ModelFetcher::new(FetchConfig::from_env(), Arc::new(InMemoryAcceptanceStore::new()));
//! let model = fetcher.fetch(manifests.get("rf-detr-n").expect("built in")).await?;
//! let detector = RfDetr::new(&model, &OnnxOptions::default())?;
//!
//! let runtime = VisionRuntime::builder().detector(Arc::new(detector)).build()?;
//! let bytes = std::fs::read("street.jpg").expect("a photo");
//! let photo = SourceImage::decode(&bytes, &DecodeLimits::default())?;
//! let found = runtime
//! .detect(&VisionCx::new(), &photo, &DetectQuery::Classes(vec!["person".into()]))
//! .await?;
//! for region in &found.value {
//! println!("{:?} {:?} {:?}", region.label, region.score, region.shape.bbox());
//! }
//! # Ok(())
//! # }
//! ```
pub use EfficientSam;
pub use RfDetr;
pub use Sam2;
pub use ;
pub use ;
pub use SigLip2;
pub use YuNet;