A fast CLI tool for image classification using MegaDetector v1000, designed for culling large photo collections.
- Object Detection: Uses MegaDetector v1000-larch for 3-class detection (animal, person, vehicle)
- RAW Support: Handles CR2, CR3, NEF, ARW, DNG files (extracts embedded JPEG preview)
- Quality Scoring: Composite IQA score (sharpness, exposure, contrast, resolution)
- Flexible Filtering: Filter by class, quality threshold, with inverse support
- JSON Output: Machine-readable output for integration with other tools
- Debug Mode: Saves annotated images with bounding boxes
- Pipe-friendly: Default output is just paths for easy shell integration
- Rust 1.70+ (install via rustup)
git clone <repo-url>
cd bof5
cargo build --release
# install locally
cp target/release/bof /usr/local/bin/Model is not included : it's downloaded from a repo, and converted. See ./model/README.md
cargo run --release -- -t 50 --json ./public/imagesbof [OPTIONS] <PATH><PATH>- Path to image folder
| Flag | Description |
|---|---|
-t, --threshold <N> |
Quality score threshold 0-100 (default: 0 = all) |
-d, --threshold-detection <N> |
Detection confidence threshold 0-100 (default: 20) |
-f, --filter <tags> |
Filter by class (comma-separated: animal,person,vehicle) |
--inverse-threshold |
Return images BELOW quality threshold instead of above |
--inverse-filter |
Exclude filtered classes instead of including them |
--quality-mode <MODE> |
Aggregate quality scores: max, mean, or min (default: max) |
--debug <FOLDER> |
Save annotated images to specified folder |
-v, --verbose |
Verbose output (auto-enabled with --debug) |
--json |
Output results as JSON array |
-h, --help |
Print help |
# Basic detection - outputs paths only (pipe-friendly)
bof ./photos
# Verbose output with details
bof -v ./photos
# Filter animals and copy to best/ folder
bof -f animal ./photos | xargs -I {} cp {} ./best/
# Save debug images with ROI boxes
bof --debug ./debug_output -f animal ./photos
# JSON output for scripting
bof --json ./photos > results.json
# High quality animals only (quality score >= 60)
bof -f animal -t 60 -v ./photos
# Exclude persons from results
bof -f person --inverse-filter ./photos
# Get low quality images (below threshold 30)
bof -t 30 --inverse-threshold ./photos- Standard: JPG, JPEG, PNG, WebP, TIFF
- RAW: CR2, CR3 (Canon), NEF (Nikon), ARW (Sony), DNG
image1.jpg
image2.CR3
subfolder/image3.png
image.jpg:
animal Q:72 [RES:85 CONF:90 SHARP:65 EXP:80 CONTR:70]
image.jpg
Verbose info goes to stderr, paths to stdout for clean piping.
[
{
"path": "image.jpg",
"detections": [
{
"class": "animal",
"confidence": 0.902,
"quality": {
"score": 72.0,
"sharpness": 65.0,
"exposure": 80.0,
"contrast": 70.0,
"resolution": 85.0
},
"bbox": { "x": 1912, "y": 1106, "width": 994, "height": 1536 }
}
]
}
]- Preprocessing: Images resized to 640x640, normalized to [0,1]
- Inference: MegaDetector v1000-larch ONNX model via ONNX Runtime
- Post-processing: Non-Maximum Suppression (IoU threshold 0.45)
- Quality Scoring: Composite score from sharpness, exposure, contrast, and resolution
The model detects 3 classes: animal, person, vehicle.
- yolo-rust-ort - YOLOv8/v10 in Rust
- yolo-rs - YOLO inference crate
- ort - ONNX Runtime Rust bindings
MIT