Skip to main content

spacelab_vision/
lib.rs

1//! **deepvision** — the CNN forward-pass primitives, the third Phase-8 line.
2//!
3//! The building blocks that run a convolutional network over space imagery: [`conv2d`], [`relu`],
4//! [`max_pool2d`], [`dense`] and [`softmax`]. Pure Rust, `no_std`, `libm` only — **no ML framework**,
5//! so it links anywhere (embedded / offline) and adds no heavy dependency tree. Tensors are
6//! caller-provided row-major `f64` slices in **HWC** layout (height, width, channel); a caller sizes
7//! the outputs with [`conv_out_dim`] / [`pool_out_dim`].
8//!
9//! This is the inference kernel. Loading *trained* models exported to ONNX is the opt-in `onnx`
10//! module (`--features onnx`, pure-Rust `tract`); it pulls a `std`-only dependency and stays out of
11//! the default `no_std` build.
12
13#![cfg_attr(not(any(test, feature = "std")), no_std)]
14
15pub mod nn;
16
17#[cfg(any(feature = "std", test))]
18pub mod model;
19
20#[cfg(any(feature = "std", test))]
21pub mod graph;
22
23#[cfg(any(feature = "std", test))]
24pub mod detect;
25
26#[cfg(feature = "onnx")]
27pub mod onnx;
28
29pub use nn::{
30    BatchNormParams, Conv2d, ConvTranspose2d, add, batch_norm, concat_channels, conv_out_dim,
31    conv_transpose2d, conv2d, dense, global_avg_pool, max_pool2d, pad2d, pool_out_dim, relu,
32    sigmoid, softmax,
33};
34
35#[cfg(any(feature = "std", test))]
36pub use model::{Layer, Sequential, weights_from_le_bytes};
37
38#[cfg(any(feature = "std", test))]
39pub use graph::{Graph, Node, Op};
40
41#[cfg(any(feature = "std", test))]
42pub use detect::{BBox, decode_box, generate_anchors, nms};
43
44#[cfg(feature = "onnx")]
45pub use onnx::{OnnxError, OnnxModel, threshold_mask};