Skip to content

fxi/bof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bof - Best of Photo

A fast CLI tool for image classification using MegaDetector v1000, designed for culling large photo collections.

Features

  • 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

Installation

Prerequisites

  • Rust 1.70+ (install via rustup)

Build

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

Usage

cargo run --release -- -t 50 --json ./public/images
bof [OPTIONS] <PATH>

Arguments

  • <PATH> - Path to image folder

Options

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

Examples

# 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

Supported Formats

  • Standard: JPG, JPEG, PNG, WebP, TIFF
  • RAW: CR2, CR3 (Canon), NEF (Nikon), ARW (Sony), DNG

Output

Default Mode (pipe-friendly)

image1.jpg
image2.CR3
subfolder/image3.png

Verbose Mode (-v)

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.

JSON Mode

[
  {
    "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 }
      }
    ]
  }
]

How It Works

  1. Preprocessing: Images resized to 640x640, normalized to [0,1]
  2. Inference: MegaDetector v1000-larch ONNX model via ONNX Runtime
  3. Post-processing: Non-Maximum Suppression (IoU threshold 0.45)
  4. Quality Scoring: Composite score from sharpness, exposure, contrast, and resolution

Detection Classes

The model detects 3 classes: animal, person, vehicle.

Similar Projects

License

MIT

About

bof : best of fotos. Use image classifier to quickly cull large set of images. Using the command line.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors