Native object detection, instance segmentation, semantic segmentation, depth estimation, and image classification in Rust with Burn
Montgomery is an experimental Rust computer-vision stack:
- Computer vision inference on CPU or GPU
- WGPU training with validation, resumable checkpoints, and ready-to-use exports
- Detection, instance segmentation, semantic segmentation, depth estimation, and classification
- Burnpack and ONNX export
Normal inference needs no Python, PyTorch, or ONNX Runtime.
| Model | Variants | Tasks |
|---|---|---|
| YOLOX | nano, tiny, s, m, l, x |
Detect |
| YOLOv3 | tinyu |
Detect |
| YOLOv8 | n, s, m, l, x |
Detect, segment, classify |
| YOLOv10 | n, s, m, b, l, x |
Detect |
| YOLO11 | n, s, m, l, x |
Detect, segment, classify |
| YOLO12 | n, s, m, l, x |
Detect |
| YOLO26 | n, s, m, l, x |
Detect, segment, semantic, depth, classify |
use montgomery::Model;
fn main() -> montgomery::Result<()> {
let model = Model::new("yolo26n.bpk")?;
let prediction = model.inference("image.jpg")?;
for detection in prediction.detections().expect("detection model") {
println!("{}: {:.1}%", detection.class_name, detection.confidence * 100.0);
}
Ok(())
}montgomery predict --model best.bpk --source image.jpg --jsonBenchmark cold-start and steady-state inference without loading an image:
montgomery bench --device gpu --model best.bpkInspect and prepare datasets entirely in Rust, without loading a model:
montgomery data --path dataset/data.yaml
montgomery data inspect --path dataset/data.yaml --verify-images --check
montgomery data convert --path dataset/data.yaml --to detect --out-dir boxes
montgomery data convert --path boxes/data.yaml --to classify --out-dir crops --imgsz 224
montgomery data resize --path crops/data.yaml --imgsz 224 --mode letterbox --out-dir smallInspection reports image/label counts, label types, class balance, image sizes, missing labels,
and split leakage. Segmentation-to-detection retains images and replaces masks with boxes;
classification conversion crops one image per object. Resizing preserves labels and splits.
--imgsz 224 fits within 224×224 without stretching or upscaling; --mode letterbox produces
an exact 224×224 padded image, and --mode stretch produces an exact size by changing aspect ratio.
Every transformation requires --out-dir DIRECTORY for a new dataset or --override to replace
the source dataset after processing. Override retains a recovery backup; existing output
directories are refused with --out-dir.
Use --dry-run to preview a transformation and --json for scripting. YOLO, COCO, and class-folder
datasets are supported in the standard build, without the training feature.
See the dataset guide for manifests, options, and complete workflows.
# Fresh initialization
montgomery train --architecture yolo26n --data dataset.yaml --epochs 100
# Pretrained initialization
montgomery train --model yolo26n.bpk --data dataset.yaml --epochs 100
# Automatically choose a hardware-specific batch size
montgomery train --model yolo26n.bpk --data dataset.yaml --batch -1 --epochs 100
# Exact continuation (model and dataset come from the training checkpoint)
montgomery train --resume runs/detect/train-<timestamp>-<pid>/checkpoints/lastExactly one initialization mode is required: --architecture means scratch, --model requires a
pretrained .bpk, and --resume requires a full native training checkpoint. A Burnpack initializes
a new run; it is not a resumable optimizer checkpoint.
Every run contains:
results.csv,results.svg, andvalidation.jsonlexports/best.bpkandexports/last.bpkcheckpoints/bestandcheckpoints/last
Only the best and latest resumable models are retained.
Use --save-period to control recovery checkpoints and --workers to override automatic CPU
worker selection.
--batch -1 runs isolated WGPU optimizer-step probes, finds the largest fitting microbatch up to
the training-set size (capped at 1024), and uses 80% of that verified maximum for runtime headroom.
montgomery val --model best.bpk --data dataset.yamlReports task-appropriate metrics for the dataset's validation split. Use --json for structured
output, or --checkpoint checkpoints/best to validate a resumable training checkpoint.
montgomery export --model yolo26n.bpk --format onnxThis reads the explicit Burnpack and writes yolo26n.onnx; use --output to select another path.
The offline exporter validates the graph with ONNX Runtime. Setup details are in tools/onnx/README.md.
Stable Rust is the only requirement to start development
git clone https://github.com/boquila/montgomery.git && cd montgomery
cargo testBefore you open a pull request, run the quick checks:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo testChanges to training or augmentation also need these:
cargo clippy --features training --all-targets -- -D warnings
cargo test --features training --libCI runs the full set, including the minimal-library Clippy pass and the slow every-scale model tests.
See docs/MODEL_BRINGUP.md for new model families.
Same docs/dog_bike_man.jpg through the YOLO26n family: classification top-5,
detection boxes, per-object instance masks, the dense semantic map, and the depth map
in meters.
Montgomery is AGPL-3.0