Skip to contents

Reads from the filtered folder (default) or the standardized folder (birdnet$input), runs BirdNET in parallel worker processes, and writes raw detections in batches to <detections>/<run_id>/batches/.

Usage

pam_detect(cfg, master = NULL, sample_n = NULL, seed = 1L, force = FALSE)

Arguments

cfg

A pam_config object (uses the birdnet section).

master

Optional Stage 1 master table; if NULL it is read from metadata/audio_master.csv.

sample_n

If set, process a random sample of this many files (for pilots). The same seed gives the same sample.

seed

Seed for the pilot sample.

force

If TRUE, delete this run's earlier results and start over.

Value

Invisibly, a list: n_pending, n_done, n_failed, n_detections, run_dir.

Details

BirdNET runs in pamflow's Python inference environment (see pam_birdnet_setup()) using the birdnet Python package, which does its own multiprocessing: birdnet$workers worker processes each load the model (an unset value means half of the physical cores). top_k limits the species kept per 3 s segment (NULL = all above min_confidence). Resumable. A file is marked done (<run_dir>/done.txt) only after its batch file is on disk, and files with no detections count as done. If a crash happens between writing a batch and updating the checkpoint, those files are re-run, and pam_assemble_detections() removes the duplicates. Per-file outcomes (seconds, errors) go to file_results.csv; settings and the birdnet package version go to run_settings_*.yml. Run with pam_run_stage("03_detect", pam_detect, cfg).

References

Kahl, S., Wood, C. M., Eibl, M. and Klinck, H. (2021). BirdNET: A deep learning solution for avian diversity monitoring. Ecological Informatics, 61, 101236. doi:10.1016/j.ecoinf.2021.101236

Examples

if (FALSE) { # \dontrun{
# needs the BirdNET Python environment (pam_birdnet_setup("inference")) and your model
cfg <- pam_config_read("config/config.yml")
res <- pam_run_stage("03_detect", pam_detect, cfg)
} # }