birdnet package

Subpackages

Submodules

birdnet.argparse_helper module

birdnet.backends module

birdnet.base module

birdnet.benchmark_script module

birdnet.globals module

birdnet.helper module

birdnet.local_data module

birdnet.logging_utils module

birdnet.model_loader module

Module for loading models. Provides functions to load official and custom models.

birdnet.model_loader.load(model_type, version, backend, /, *, precision='fp32', lang='en_us', **model_kwargs)
Return type:

ModelBase

birdnet.model_loader.load_custom(model_type, version, backend, model, species_list, /, *, precision='fp32', check_validity=True, **model_kwargs)
Return type:

ModelBase

birdnet.model_loader.load_perch_v2(device)
Return type:

AcousticModelPerchV2

birdnet.shm module

birdnet.utils module

Module contents

class birdnet.AcousticDataEncodingResult(tensor, input_durations, segment_duration_s, overlap_duration_s, speed, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version)

Bases: AcousticEncodingResultBase

Attributes:
embeddings
embeddings_masked
emd_dim
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
overlap_duration_s
segment_duration_s
speed

Methods

load

save

unprocessable_inputs

class birdnet.AcousticDataPredictionResult(tensor, species_list, input_durations, segment_duration_s, overlap_duration_s, speed, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version)

Bases: AcousticPredictionResultBase

Attributes:
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
n_species
overlap_duration_s
segment_duration_s
species_ids
species_list
species_masked
species_probs
speed
top_k
unprocessable_inputs

Methods

load

save

to_arrow_table

to_csv

to_dataframe

to_parquet

to_structured_array

class birdnet.AcousticEncodingResultBase(inputs, input_durations, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version, segment_duration_s, overlap_duration_s, speed, tensor)

Bases: AcousticResultBase

Attributes:
embeddings
embeddings_masked
emd_dim
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
overlap_duration_s
segment_duration_s
speed

Methods

load

save

unprocessable_inputs

property embeddings: ndarray
property embeddings_masked: ndarray
property emd_dim: int
property max_n_segments: int
property memory_size_mb: float
unprocessable_inputs()
Return type:

ndarray

class birdnet.AcousticEncodingSession(species_list, model_path, model_segment_size_s, model_sample_rate, model_is_custom, model_sig_fmin, model_sig_fmax, model_version, model_backend_type, model_backend_custom_kwargs, model_emb_dim, *, n_producers, n_workers, batch_size, prefetch_ratio, overlap_duration_s, speed, bandpass_fmin, bandpass_fmax, half_precision, max_audio_duration_min, show_stats, progress_callback, device, max_n_files)

Bases: AcousticSessionBase

Methods

cancel

end

run

run_arrays

run(inputs)
Return type:

AcousticFileEncodingResult

run_arrays(inputs)
Return type:

AcousticDataEncodingResult

class birdnet.AcousticFileEncodingResult(tensor, files, file_durations, segment_duration_s, overlap_duration_s, speed, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version)

Bases: AcousticEncodingResultBase

Attributes:
embeddings
embeddings_masked
emd_dim
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
overlap_duration_s
segment_duration_s
speed

Methods

load

save

unprocessable_inputs

class birdnet.AcousticFilePredictionResult(tensor, files, species_list, file_durations, segment_duration_s, overlap_duration_s, speed, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version)

Bases: AcousticPredictionResultBase

Attributes:
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
n_species
overlap_duration_s
segment_duration_s
species_ids
species_list
species_masked
species_probs
speed
top_k
unprocessable_inputs

Methods

get_unprocessed_files

load

save

to_arrow_table

to_csv

to_dataframe

to_parquet

to_structured_array

get_unprocessed_files()
Return type:

set[Path]

class birdnet.AcousticModelPerchV2(model_path, species_list, is_custom_model, backend_type, backend_kwargs)

Bases: AcousticModelBase

Attributes:
is_custom_model
model_path
n_species
species_list

Methods

encode

encode_session

get_embeddings_dim

get_sample_rate

get_segment_size_s

get_segment_size_samples

get_sig_fmax

get_sig_fmin

get_version

load

load_custom

predict

predict_session

encode(inp, /, *, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticEncodingResultBase

encode_session(*, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticEncodingSession

classmethod get_embeddings_dim()
Return type:

int

classmethod get_sample_rate()
Return type:

int

classmethod get_segment_size_s()
Return type:

float

classmethod get_segment_size_samples()
Return type:

int

classmethod get_sig_fmax()
Return type:

int

classmethod get_sig_fmin()
Return type:

int

classmethod get_version()
Return type:

Literal['2.4']

classmethod load(model_path, species_list, backend_type, backend_kwargs)
Return type:

AcousticModelPerchV2

classmethod load_custom(model_path, species_list, backend_type, backend_kwargs, check_validity)
Return type:

AcousticModelPerchV2

predict(inp, /, *, top_k=5, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, bandpass_fmin=0, bandpass_fmax=15000, speed=1.0, apply_sigmoid=False, sigmoid_sensitivity=None, default_confidence_threshold=0.1, custom_confidence_thresholds=None, custom_species_list=None, half_precision=False, max_audio_duration_min=None, device='CPU', show_stats=None, progress_callback=None)
Return type:

AcousticPredictionResultBase

predict_session(*, top_k=5, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, apply_sigmoid=False, sigmoid_sensitivity=None, default_confidence_threshold=0.1, custom_confidence_thresholds=None, custom_species_list=None, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticPredictionSession

class birdnet.AcousticModelV2_4(model_path, species_list, is_custom_model, backend_type, backend_kwargs)

Bases: AcousticModelBase

Attributes:
is_custom_model
model_path
n_species
species_list

Methods

encode

encode_session

get_embeddings_dim

get_sample_rate

get_segment_size_s

get_segment_size_samples

get_sig_fmax

get_sig_fmin

get_version

load

load_custom

predict

predict_session

encode(inp, /, *, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticEncodingResultBase

encode_session(*, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticEncodingSession

classmethod get_embeddings_dim()
Return type:

int

classmethod get_sample_rate()
Return type:

int

classmethod get_segment_size_s()
Return type:

float

classmethod get_segment_size_samples()
Return type:

int

classmethod get_sig_fmax()
Return type:

int

classmethod get_sig_fmin()
Return type:

int

classmethod get_version()
Return type:

Literal['2.4']

classmethod load(model_path, species_list, backend_type, backend_kwargs)
Return type:

AcousticModelV2_4

classmethod load_custom(model_path, species_list, backend_type, backend_kwargs, check_validity)
Return type:

AcousticModelV2_4

predict(inp, /, *, top_k=5, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, bandpass_fmin=0, bandpass_fmax=15000, speed=1.0, apply_sigmoid=True, sigmoid_sensitivity=1.0, default_confidence_threshold=0.1, custom_confidence_thresholds=None, custom_species_list=None, half_precision=False, max_audio_duration_min=None, device='CPU', show_stats=None, progress_callback=None)
Return type:

AcousticPredictionResultBase

predict_session(*, top_k=5, n_producers=1, n_workers=None, batch_size=1, prefetch_ratio=1, overlap_duration_s=0, speed=1.0, bandpass_fmin=0, bandpass_fmax=15000, apply_sigmoid=True, sigmoid_sensitivity=1.0, default_confidence_threshold=0.1, custom_confidence_thresholds=None, custom_species_list=None, half_precision=False, max_audio_duration_min=None, show_stats=None, progress_callback=None, device='CPU', max_n_files=65536)
Return type:

AcousticPredictionSession

class birdnet.AcousticPredictionResultBase(inputs, input_durations, model_path, model_fmin, model_fmax, model_sr, model_precision, model_version, species_list, segment_duration_s, overlap_duration_s, speed, tensor)

Bases: AcousticResultBase

Attributes:
input_durations
inputs
max_n_segments
memory_size_mb
model_fmax
model_fmin
model_path
model_precision
model_sr
model_version
n_inputs
n_species
overlap_duration_s
segment_duration_s
species_ids
species_list
species_masked
species_probs
speed
top_k
unprocessable_inputs

Methods

load

save

to_arrow_table

to_csv

to_dataframe

to_parquet

to_structured_array

property max_n_segments: int
property memory_size_mb: float
property n_species: int
property species_ids: ndarray
property species_list: ndarray
property species_masked: ndarray
property species_probs: ndarray
to_arrow_table()
Return type:

Table

to_csv(path, *, encoding='utf-8', buffer_size_kb=1024, silent=False)
Return type:

None

to_dataframe()
Return type:

DataFrame

to_parquet(path, *, compression='snappy', compression_level=None, silent=False)
Return type:

None

to_structured_array()
Return type:

ndarray

property top_k: int
property unprocessable_inputs: ndarray
class birdnet.AcousticPredictionSession(species_list, model_path, model_segment_size_s, model_sample_rate, model_is_custom, model_sig_fmin, model_sig_fmax, model_version, model_backend_type, model_backend_custom_kwargs, *, top_k, n_producers, n_workers, batch_size=1, prefetch_ratio=1, overlap_duration_s, speed, bandpass_fmin, bandpass_fmax, apply_sigmoid, sigmoid_sensitivity, default_confidence_threshold, custom_confidence_thresholds, custom_species_list, half_precision=True, max_audio_duration_min, show_stats, progress_callback, device, max_n_files)

Bases: AcousticSessionBase

Methods

cancel

end

run

run_arrays

run(inputs)
Return type:

AcousticFilePredictionResult

run_arrays(inputs)
Return type:

AcousticDataPredictionResult

class birdnet.AcousticProgressStats(worker_speed_xrt=None, worker_speed_seg_per_s=None, progress=None, est_remaining_time_s=None, progress_current=0, progress_total=None)

Bases: object

Attributes:
est_remaining_time_s
progress
progress_total
worker_speed_seg_per_s
worker_speed_xrt
est_remaining_time_s: float | None = None
progress: float | None = None
progress_current: int | None = 0
progress_total: int | None = None
worker_speed_seg_per_s: float | None = None
worker_speed_xrt: float | None = None
class birdnet.GeoModelV2_4(model_path, species_list, is_custom_model, backend_type, backend_kwargs)

Bases: GeoModelBase

Attributes:
is_custom_model
model_path
n_species
species_list

Methods

get_model_type

get_version

load

load_custom

predict

predict_session

classmethod get_model_type()
Return type:

Literal['acoustic', 'geo']

classmethod get_version()
Return type:

Literal['2.4']

classmethod load(model_path, species_list, backend_type, backend_kwargs)
Return type:

GeoModelV2_4

classmethod load_custom(model_path, species_list, backend_type, backend_kwargs, check_validity)
Return type:

GeoModelV2_4

predict(latitude, longitude, /, *, week=None, min_confidence=0.03, half_precision=False, device='CPU')
Return type:

GeoPredictionResult

predict_session(*, min_confidence=0.03, half_precision=False, device='CPU')
Return type:

GeoPredictionSession

class birdnet.GeoPredictionResult(model_path, model_version, model_precision, latitude, longitude, week, species_masked, species_ids, species_probs, species_list)

Bases: ResultBase

Attributes:
latitude
longitude
memory_size_mb
model_path
model_precision
model_version
n_species
species_ids
species_list
species_masked
species_probs
week

Methods

load

save

to_arrow_table

to_csv

to_dataframe

to_set

to_structured_array

to_txt

property latitude: int
property longitude: int
property memory_size_mb: float
property n_species: int
property species_ids: ndarray
property species_list: ndarray
property species_masked: ndarray
property species_probs: ndarray
to_arrow_table(sort_by='species')
Return type:

Table

to_csv(csv_out_path, sort_by='species', encoding='utf8')
Return type:

None

to_dataframe(sort_by='species')
Return type:

DataFrame

to_set()
Return type:

set[str]

to_structured_array(sort_by='species')
Return type:

ndarray

to_txt(txt_out_path, sort_by='species', encoding='utf8')
Return type:

None

property week: int
class birdnet.GeoPredictionSession(species_list, model_path, model_is_custom, model_version, model_backend_type, model_backend_custom_kwargs, *, min_confidence, half_precision, device)

Bases: GeoSessionBase

Methods

run

run(latitude, longitude, /, *, week=None)
Return type:

GeoPredictionResult

birdnet.get_package_logger()
Return type:

Logger

birdnet.load(model_type, version, backend, /, *, precision='fp32', lang='en_us', **model_kwargs)
Return type:

ModelBase

birdnet.load_custom(model_type, version, backend, model, species_list, /, *, precision='fp32', check_validity=True, **model_kwargs)
Return type:

ModelBase

birdnet.load_perch_v2(device)
Return type:

AcousticModelPerchV2