BatBot CLI

BatBot is the machine learning interface for the Kitware BatAI project. This page specifies the Command Line Interface (CLI) to interact with all of the algorithms and machine learning models that have been pretrained for inference in a production environment.

batbot

BatBot CLI

Usage

batbot [OPTIONS] COMMAND [ARGS]...

batch

Classify a list of WAV files (legacy alias for classify-wav).

Usage

batbot batch [OPTIONS] [FILEPATHS]...

Options

--config <config>

Which ML model to use for inference

Options:

mobilenet

--output <output>

Path to output JSON (if unspecified, results are printed to screen)

--num-workers <num_workers>

Number of concurrent ONNX inference workers.

Default:

1

--spectrogram-dir <spectrogram_dir>

Keep generated spectrograms in this directory.

--progress, --no-progress

Show processing progress on stderr.

Default:

True

--provider <provider>

Inference device. Explicit CUDA selection fails if GPU initialization fails.

Default:

'auto'

Options:

auto | cpu | cuda | coreml

--preprocess-workers <preprocess_workers>

Number of processes generating WAV spectrograms before batch inference.

Default:

1

Arguments

FILEPATHS

Optional argument(s)

classify

Classify one or more spectrogram image files.

Usage

batbot classify [OPTIONS] SPECTROGRAMS...

Options

-o, --output <output>

Path to output JSON (defaults to stdout).

--batch-size <batch_size>
Default:

10

--num-workers <num_workers>

Number of concurrent ONNX inference workers.

Default:

1

--top-k <top_k>
Default:

5

--progress, --no-progress

Show processing progress on stderr.

Default:

True

--provider <provider>

Inference device. Explicit CUDA selection fails if GPU initialization fails.

Default:

'auto'

Options:

auto | cpu | cuda | coreml

Arguments

SPECTROGRAMS

Required argument(s)

classify-bulk

Recursively classify a large folder and report species counts.

Usage

batbot classify-bulk [OPTIONS] INPUTS...

Options

--input-type <input_type>

Limit inputs to spectrograms, WAV files, or detect both.

Default:

'auto'

Options:

auto | spectrogram | wav

--recursive, --no-recursive
Default:

True

-o, --output <output>

Path to output JSON (defaults to stdout).

--spectrogram-dir <spectrogram_dir>

Keep spectrograms generated for WAV inputs in this directory.

--batch-size <batch_size>
Default:

10

--num-workers <num_workers>

Number of concurrent ONNX inference workers.

Default:

1

--top-k <top_k>
Default:

5

--progress, --no-progress

Show processing progress on stderr.

Default:

True

--provider <provider>

Inference device. Explicit CUDA selection fails if GPU initialization fails.

Default:

'auto'

Options:

auto | cpu | cuda | coreml

--preprocess-workers <preprocess_workers>

Number of processes generating WAV spectrograms before batch inference.

Default:

1

Arguments

INPUTS

Required argument(s)

classify-wav

Create spectrograms from WAV files and classify each recording.

Usage

batbot classify-wav [OPTIONS] WAV_FILES...

Options

-o, --output <output>

Path to output JSON (defaults to stdout).

--spectrogram-dir <spectrogram_dir>

Keep generated spectrograms in this directory.

--batch-size <batch_size>
Default:

10

--num-workers <num_workers>

Number of concurrent ONNX inference workers.

Default:

1

--top-k <top_k>
Default:

5

--progress, --no-progress

Show processing progress on stderr.

Default:

True

--provider <provider>

Inference device. Explicit CUDA selection fails if GPU initialization fails.

Default:

'auto'

Options:

auto | cpu | cuda | coreml

--preprocess-workers <preprocess_workers>

Number of processes generating WAV spectrograms before batch inference.

Default:

1

Arguments

WAV_FILES

Required argument(s)

example

Run a test of the pipeline on an example WAV with the default configuration.

Usage

batbot example [OPTIONS]

fetch

Fetch the required machine learning ONNX model for the classifier

Usage

batbot fetch [OPTIONS]

Options

--config <config>

Which ML model to use for inference

Options:

mobilenet

--pull

Download the mirrored model even when a bundled copy is available.

pipeline

Usage

batbot pipeline [OPTIONS] FILEPATH

Options

--output <output_path>

Path to output folder for the results

Arguments

FILEPATH

Required argument

preprocess

Generate compressed spectrogram images for input wav files into the same or a specified output directory. Takes one or more space separated arguments of filepaths to process. If given a directory name argument, will recursively search through the directory and all subfolders to find all contained *.wav files. Alternatively, the argument can be given as a string using wildcard ** for folders and/or * in filenames (if ** wildcard is used, will recursively search through all subfolders).

Examples:
batbot preprocess ../data -o ./tmp
batbot preprocess “../data/**/*.wav”
batbot preprocess ../data -o ./tmp -n 32
batbot preprocess ../data -o ./tmp -n 32 -fm
batbot preprocess ../data -o ./tmp -f –dry-run –output-json dry_run.json
batbot preprocess ../data -o ./tmp –cleanup

Usage

batbot preprocess [OPTIONS] [FILEPATHS]...

Options

-o, --output-dir <output_dir>

Processed file root output directory. Outputs will attempt to mirror input file directory structure if given multiple inputs (unless –no-file-structure flag is given). Defaults to current working directory.

-m, --process-metadata

Use a slower version of the pipeline which increases spectogram compression quality and also outputs bat call metadata.

-f, --force-overwrite

Force overwriting of compressed spectrogram and other output files.

-n, --num-workers <num_workers>

Number of parallel workers to use. Set to zero for serial computation only.

--output-json <output_json>

Path to output JSON (if unspecified, output file locations are printed to screen).

-d, --dry-run

List out all the audio files to be loaded and all the anticipated output files. Additionally lists all “extra” files in the output directory that would be deleted if using the –cleanup flag.

--cleanup

For the given input filepaths and –output-dir arguments, delete any extra files that would not have been created by the batbot preprocess. Skips hidden files starting with “.”. Acts as if –force-overwrite flag is given (does not delete existing, preprocessed outputs). WARNING: This will delete files, recommend running with the –dry-run flag first and carefully examining the output!

--no-file-structure

Write outputs directly into the output directory. Duplicate filenames are rejected.

Arguments

FILEPATHS

Optional argument(s)