birdnet_onnx/
lib.rs

1//! # birdnet-onnx
2//!
3//! A Rust library for running inference on `BirdNET` and `Perch` ONNX models.
4//!
5//! ## Supported Models
6//!
7//! - **`BirdNET` v2.4**: 48kHz, 3s segments (144,000 samples)
8//! - **`BirdNET` v3.0**: 32kHz, 5s segments (160,000 samples)
9//! - **`Perch` v2**: 32kHz, 5s segments (160,000 samples)
10//!
11//! ## Example
12//!
13//! ```ignore
14//! use birdnet_onnx::Classifier;
15//!
16//! let classifier = Classifier::builder()
17//!     .model_path("model.onnx")
18//!     .labels_path("labels.txt")
19//!     .with_cuda()
20//!     .build()?;
21//!
22//! let result = classifier.predict(&audio_segment)?;
23//! for pred in &result.predictions {
24//!     println!("{}: {:.1}%", pred.species, pred.confidence * 100.0);
25//! }
26//! ```
27
28// Crate-level lint configuration
29#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
30#![deny(unsafe_code)]
31#![deny(clippy::unwrap_used, clippy::expect_used)]
32#![allow(clippy::module_name_repetitions)]
33
34mod classifier;
35mod detection;
36mod error;
37pub mod execution_providers;
38mod labels;
39mod postprocess;
40mod rangefilter;
41mod runtime;
42pub mod tensorrt_config;
43#[cfg(test)]
44pub mod testutil;
45mod types;
46
47pub use classifier::{Classifier, ClassifierBuilder};
48pub use error::{Error, Result};
49pub use execution_providers::available_execution_providers;
50pub use rangefilter::{
51    RangeFilter, RangeFilterBuilder, calculate_week, validate_coordinates, validate_date,
52};
53pub use runtime::init_runtime;
54pub use tensorrt_config::TensorRTConfig;
55pub use types::{
56    ExecutionProviderInfo, LabelFormat, LocationScore, ModelConfig, ModelType, Prediction,
57    PredictionResult,
58};
59
60// Re-export ort execution providers module for convenience
61pub use ort::execution_providers as ort_execution_providers;