CLI API

fb_predict

Inference CLI script for flatbug.

A comprehensive CLI API for flatbug inference with support for hyperparameter configuration, flexible input parsing, output format specification, and hardware specification.

Usage:

fb_predict -i INPUT_PATH_OR_DIRECTORY -o OUTPUT_DIRECTORY [OPTIONS]

Options:
-h, --help

show this help message and exit

-i INPUT, --input INPUT

A image file or a directory of image files

-o OUTPUT_DIR, --output OUTPUT_DIR

The result directory

-w MODEL_WEIGHTS, --model-weights MODEL_WEIGHTS

The .pt file

-p INPUT_PATTERN, --input-pattern INPUT_PATTERN

The pattern to match the images. Default is ‘[^/]*.([jJ][pP][eE]{0,1}[gG]|[pP][nN][gG])$’ i.e. jpg/jpeg/png case-insensitive.

-n MAX_IMAGES, --max-images MAX_IMAGES

Maximum number of images to process. Default is None. Truncates in alphabetical order.

-R, --recursive

Process images nested within subdirectories of the input.

-s SCALE_BEFORE, --scale-before SCALE_BEFORE

Downscale the image before detection, but crops from the original image.

--single-scale

Use single scale.

-g GPU, --gpu GPU

Which device to use for inference. Default is ‘cuda:0’, i.e. the first GPU.

-d DTYPE, --dtype DTYPE

Which dtype to use for inference. Default is ‘float16’.

-f, --fast

Use fast mode.

--config CONFIG

The config file.

--no-crops

Do not save the crops.

--no-overviews

Do not save the overviews.

--no-metadata

Do not save the metadata.

--only-overviews

Only save the overviews.

--long-format

Use long format for storing results.

-S, --no-save

Do not save the results.

-C, --no-compiled-coco

Skip the production of a compiled COCO file (for all images).

-v, --verbose

Verbose mode.

fb_eval

Custom flatbug evaluation script. Requires prediction to have been run already, and ground truth labels should be supplied in COCO format.

For end-to-end use the script scripts/eval/end_to_end_eval.sh (requires R for summary statistics and figures).

Usage:

fb_evaluate -p PREDICTIONS -g GROUND_TRUTH -I IMAGE_DIRECTORY -o OUTPUT_DIRECTORY [OPTIONS]

Options:
-h, --help

show this help message and exit

-p PREDICTIONS, --predictions PREDICTIONS

Path or pattern to the predictions files

-g GROUND_TRUTH, --ground_truth GROUND_TRUTH

Path to the ground truth file

-I IMAGE_DIRECTORY, --image_directory IMAGE_DIRECTORY

Path to the image directory

-o OUTPUT_DIRECTORY, --output_directory OUTPUT_DIRECTORY

Path to the output directory

--config CONFIG

Path to the configuration file

-P, --plot

Plot the matches and the IoU matrix

-b, --no_boxes

Do not plot the bounding boxes

-c, --coco_predictions

Whether the predictions are already in a COCO format (legacy)

-s SCALE, --scale SCALE

Scale of the output images. Defaults to 1. Lower is faster.

-n N

Number of images to process. Defaults to -1 (all images)

--workers WORKERS

Number of workers to use for the evaluation. Defaults to 8.

--combine

Combine the results into a single CSV file

fb_train

flatbug training script.

The flatbug training script uses a lightly modified YOLO training interface (https://docs.ultralytics.com/modes/train/), with a few additional parameters.

See scripts/experiments/best_train/default.yaml for an example training config.

Usage:

fb_train [-d DATA_DIR] [-c CONFIG_FILE] [-r]

Options:
-h, --help

show this help message and exit

-d DATA_DIR, --data-dir DATA_DIR

The directory containing the prepared data (i.e., the output of fb_prepare.py

-c CONFIG_FILE, --config-file CONFIG_FILE

A YAML-formatted config file that overrides the default training meta-parameters

-r, --resume

resume training