birdnet.acoustic.models package

Subpackages

Submodules

birdnet.acoustic.models.base module

class birdnet.acoustic.models.base.AcousticModelBase(model_path, species_list, is_custom_model, backend_type, backend_kwargs)

Bases: ModelBase, ABC

property backend_kwargs: dict[str, Any]
property backend_type: type[VersionedAcousticBackendProtocol]
abstractmethod encode(*args, **kwargs)
Return type:

AcousticEncodingResultBase

abstractmethod encode_arrays(*args, **kwargs)
Return type:

AcousticEncodingResultBase

abstractmethod encode_session(*args, **kwargs)
Return type:

AcousticEncodingSession

abstractmethod classmethod get_sample_rate()
Return type:

int

abstractmethod classmethod get_segment_size_s()
Return type:

float

abstractmethod classmethod get_segment_size_samples()
Return type:

int

abstractmethod classmethod get_sig_fmax()
Return type:

int

abstractmethod classmethod get_sig_fmin()
Return type:

int

abstractmethod classmethod get_version()

Return the string label that identifies the acoustic model version.

Return type:

Literal['2.4', '3.0']

Returns:

Registered enum constant for the supported version.

Return type:

ACOUSTIC_MODEL_VERSIONS

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

Self

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

Self

abstractmethod predict(*args, **kwargs)
Return type:

AcousticPredictionResultBase

abstractmethod predict_arrays(*args, **kwargs)
Return type:

AcousticPredictionResultBase

abstractmethod predict_session(*args, **kwargs)
Return type:

AcousticPredictionSession

birdnet.acoustic.models.base.resolve_in_graph_sigmoid_options(apply_sigmoid, apply_softmax, sigmoid_sensitivity, model_desc)

Map the score options of a model with the sigmoid in its graph onto the pipeline’s.

Returns the (apply_sigmoid, sigmoid_sensitivity) the session runs with. The graph’s own sigmoid is the result at the default sensitivity, so the pipeline’s sigmoid stays off and the scores leave the model untouched (a second sigmoid would squash every score into [0.5, 0.73]). A non-default sensitivity turns it on: the worker recovers the logits from the scores and runs the pipeline sigmoid on them, exactly as on a logit-output model. apply_sigmoid=False returns the raw model output and ignores the sensitivity, as it does for a logit-output model.

A softmax stays rejected: a score saturated at 1.0 recovers to an infinite logit, which the sigmoid clips but a softmax turns into NaN.

Return type:

tuple[bool, float | None]

birdnet.acoustic.models.base.validate_batch_size_for_backend(batch_size, backend_type)

Reject a batch the backend’s export cannot process.

Anything but an int is left to the session’s own validation.

Return type:

None

birdnet.acoustic.models.base.validate_segment_size_for_backend(segment_size_s, sample_rate, backend_type)

Reject a segment length the backend’s export cannot process.

Anything but a number is left to the session’s own validation.

Return type:

None

Module contents