birdnet-onnx
A Rust library for running inference on BirdNET and Perch ONNX models with CUDA GPU support.
Features
- Support for BirdNET v2.4, v3.0, and Perch v2 models
- Automatic model type detection from ONNX tensor shapes
- Thread-safe classifier with builder pattern
- Top-K predictions with configurable confidence threshold
- Batch inference for GPU efficiency
- CLI tool for WAV file analysis
Supported Models
| Model | Sample Rate | Segment | Embeddings |
|---|---|---|---|
| BirdNET v2.4 | 48 kHz | 3.0s | No |
| BirdNET v3.0 | 32 kHz | 5.0s | 1024-dim |
| Perch v2 | 32 kHz | 5.0s | Variable |
Installation
Add to your Cargo.toml:
[]
= { = "https://github.com/tphakala/rust-birdnet-onnx" }
Library Usage
use ;
With CUDA GPU
use ;
let classifier = builder
.model_path
.labels_path
.execution_provider
.build?;
Batch Inference
let segments: = chunk_audio_file;
let refs: = segments.iter.map.collect;
let results = classifier.predict_batch?;
CLI Usage
A basic CLI tool is included for quick testing of the library. It is not intended for production analysis tasks.
Build:
Analyze a WAV file:
With options:
Example output:
Analyzing: recording.wav (3m 21s, 48000 Hz)
Model: BirdNET v2.4 (3.0s segments, 1.5s overlap)
00:00.0 Eurasian Pygmy-Owl (92.4%)
00:01.5 Eurasian Pygmy-Owl (97.8%)
00:03.0 Eurasian Pygmy-Owl (98.5%)
...
134 segments analyzed in 1.2s
Development
Requires Task runner:
License
MIT