birdnet.acoustic.inference.core.encoding package¶
Submodules¶
birdnet.acoustic.inference.core.encoding.encoding_benchmarking module¶
- class birdnet.acoustic.inference.core.encoding.encoding_benchmarking.FullBenchmarkEmbMeta(_start_timepoint, _end_timepoint, _time_wall_time_s, _file_durations, file_formats, mem_result_total_memory_usage_MiB, mem_shm_size_file_indices_MiB, mem_shm_size_segment_indices_MiB, mem_shm_size_audio_samples_MiB, mem_shm_size_batch_sizes_MiB, mem_shm_size_flags_MiB, file_segments_total, model_segment_duration_seconds, _time_rampup_first_line_s, model_type, model_backend, model_version, model_is_custom, model_path, model_species, model_sig_fmin, model_sig_fmax, model_sample_rate, model_precision, file_segments_maximum, file_batches_processed, param_producers, param_workers, param_overlap_seconds, param_batch_size, param_prefetch_ratio, param_bandpass_fmin, param_bandpass_fmax, param_half_precision, param_devices, param_inference_library, worker_busy_average, worker_wait_time_average_milliseconds, speed_worker_xrt, speed_worker_xrt_max, _worker_avg_wall_time_s, mem_shm_ringsize, mem_memory_usage_maximum_MiB, mem_memory_usage_average_MiB, cpu_usage_maximum_pct, cpu_usage_average_pct, mem_shm_slots_average_free, mem_shm_slots_average_busy, mem_shm_slots_average_buffered, model_emb_dim)¶
Bases:
FullBenchmarkMetaBase- Attributes:
- file_count
- file_duration_average
- file_duration_maximum
- file_duration_minimum
- file_duration_sum
- hw_cpu
- hw_cpu_logical_cores
- hw_cpu_physical_cores
- hw_host
- hw_ram_GiB
- mem_shm_size_total_MiB
- mem_shm_slots_average_filled
- speed_total_audio_per_second
- speed_total_rtf
- speed_total_seg_per_second
- speed_total_xrt
- speed_worker_rtf
- speed_worker_total_audio_per_second
- speed_worker_total_seg_per_second
- sw_litert_available
- sw_os
- sw_package_version
- sw_python_implementation
- sw_python_version
- sw_start_method
- sw_tf_available
- time_begin
- time_end
- time_iso
- time_rampup_first_line
- time_wall_time
Methods
to_dict
- model_emb_dim: int¶
- class birdnet.acoustic.inference.core.encoding.encoding_benchmarking.MinimalBenchmarkEmbMeta(_start_timepoint, _end_timepoint, _time_wall_time_s, _file_durations, file_formats, mem_result_total_memory_usage_MiB, mem_shm_size_file_indices_MiB, mem_shm_size_segment_indices_MiB, mem_shm_size_audio_samples_MiB, mem_shm_size_batch_sizes_MiB, mem_shm_size_flags_MiB, file_segments_total, model_segment_duration_seconds)¶
Bases:
MinimalBenchmarkMetaBase- Attributes:
- file_count
- file_duration_average
- file_duration_maximum
- file_duration_minimum
- file_duration_sum
- mem_shm_size_total_MiB
- speed_total_audio_per_second
- speed_total_rtf
- speed_total_seg_per_second
- speed_total_xrt
- time_begin
- time_end
- time_wall_time
birdnet.acoustic.inference.core.encoding.encoding_result module¶
- class birdnet.acoustic.inference.core.encoding.encoding_result.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:
emb_dimReturn the embedding dimensionality.
embeddingsReturn the raw embedding tensor produced by the encoder.
embeddings_maskedReturn the mask that marks relevant segments across files.
- hop_duration_s
input_durationsDurations of each input in seconds.
inputsIdentifiers for each input processed by the result.
max_n_segmentsReturn the maximum segment count reserved per input.
memory_size_MiBReturn the total result memory usage including embeddings buffers.
model_fmaxUpper bound of the model’s bandpass filter.
model_fminLower bound of the model’s bandpass filter.
- model_path
- model_precision
model_srSampling rate expected by the model.
- model_version
n_inputsNumber of inputs in the result payload.
overlap_duration_sOverlap duration between sliding windows in seconds.
segment_duration_sSegment duration as configured on the inference pipeline.
speedSpeed multiplier that was applied to the inputs.
Methods
to_arrow_table()Produce a PyArrow table that serializes each embedding with timing metadata.
to_csv(path, *[, encoding, buffer_size_kb, ...])Dump the structured embeddings to a CSV file for downstream analysis.
to_dataframe()Convert the structured array into a pandas DataFrame.
to_parquet(path, *[, compression, ...])Write the contents to disk as an Arrow Parquet file.
to_structured_array()Convert the embeddings and timing metadata into a structured array.
unprocessable_inputs()Return the indices of inputs that could not be processed.
load
save
- class birdnet.acoustic.inference.core.encoding.encoding_result.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:
emb_dimReturn the embedding dimensionality.
embeddingsReturn the raw embedding tensor produced by the encoder.
embeddings_maskedReturn the mask that marks relevant segments across files.
- hop_duration_s
input_durationsDurations of each input in seconds.
inputsIdentifiers for each input processed by the result.
max_n_segmentsReturn the maximum segment count reserved per input.
memory_size_MiBReturn the total result memory usage including embeddings buffers.
model_fmaxUpper bound of the model’s bandpass filter.
model_fminLower bound of the model’s bandpass filter.
- model_path
- model_precision
model_srSampling rate expected by the model.
- model_version
n_inputsNumber of inputs in the result payload.
overlap_duration_sOverlap duration between sliding windows in seconds.
segment_duration_sSegment duration as configured on the inference pipeline.
speedSpeed multiplier that was applied to the inputs.
Methods
Produce a PyArrow table that serializes each embedding with timing metadata.
to_csv(path, *[, encoding, buffer_size_kb, ...])Dump the structured embeddings to a CSV file for downstream analysis.
to_dataframe()Convert the structured array into a pandas DataFrame.
to_parquet(path, *[, compression, ...])Write the contents to disk as an Arrow Parquet file.
Convert the embeddings and timing metadata into a structured array.
Return the indices of inputs that could not be processed.
load
save
- property emb_dim: int¶
Return the embedding dimensionality.
- Returns:
int: Number of coefficients per embedding vector.
- property embeddings: ndarray¶
Return the raw embedding tensor produced by the encoder.
- Returns:
np.ndarray: Embeddings with shape (n_inputs, n_segments, emb_dim).
- property embeddings_masked: ndarray¶
Return the mask that marks relevant segments across files.
- Returns:
np.ndarray: Boolean mask of the same shape as embeddings.
- property max_n_segments: int¶
Return the maximum segment count reserved per input.
- Returns:
int: Number of overlapping windows available per file.
- property memory_size_MiB: float¶
Return the total result memory usage including embeddings buffers.
- Returns:
float: Memory size in mebibytes.
- to_arrow_table()¶
Produce a PyArrow table that serializes each embedding with timing metadata.
- Return type:
Table
- Returns:
pa.Table: Table containing dictionary-encoded inputs and embeddings lists.
- to_csv(path, *, encoding='utf-8', buffer_size_kb=1024, silent=False)¶
Dump the structured embeddings to a CSV file for downstream analysis.
- Return type:
None
- Args:
path: File path where the CSV will be written (must end with .csv). encoding: Text encoding for the output file. buffer_size_kb: Buffer size used when writing the file. silent: Suppress progress messages when True.
- to_structured_array()¶
Convert the embeddings and timing metadata into a structured array.
- Return type:
ndarray
- Returns:
np.ndarray: Array with fields for input path, start/end times, and embedding.
- unprocessable_inputs()¶
Return the indices of inputs that could not be processed.
- Return type:
ndarray
- Returns:
np.ndarray: Boolean mask or indices for skipped inputs.
- class birdnet.acoustic.inference.core.encoding.encoding_result.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:
emb_dimReturn the embedding dimensionality.
embeddingsReturn the raw embedding tensor produced by the encoder.
embeddings_maskedReturn the mask that marks relevant segments across files.
- hop_duration_s
input_durationsDurations of each input in seconds.
inputsIdentifiers for each input processed by the result.
max_n_segmentsReturn the maximum segment count reserved per input.
memory_size_MiBReturn the total result memory usage including embeddings buffers.
model_fmaxUpper bound of the model’s bandpass filter.
model_fminLower bound of the model’s bandpass filter.
- model_path
- model_precision
model_srSampling rate expected by the model.
- model_version
n_inputsNumber of inputs in the result payload.
overlap_duration_sOverlap duration between sliding windows in seconds.
segment_duration_sSegment duration as configured on the inference pipeline.
speedSpeed multiplier that was applied to the inputs.
Methods
to_arrow_table()Produce a PyArrow table that serializes each embedding with timing metadata.
to_csv(path, *[, encoding, buffer_size_kb, ...])Dump the structured embeddings to a CSV file for downstream analysis.
to_dataframe()Convert the structured array into a pandas DataFrame.
to_parquet(path, *[, compression, ...])Write the contents to disk as an Arrow Parquet file.
to_structured_array()Convert the embeddings and timing metadata into a structured array.
unprocessable_inputs()Return the indices of inputs that could not be processed.
load
save
birdnet.acoustic.inference.core.encoding.encoding_tensor module¶
- class birdnet.acoustic.inference.core.encoding.encoding_tensor.AcousticEncodingTensor(session_id, n_inputs, emb_dim, half_precision, input_indices_dtype, segment_indices_dtype, max_segment_index)¶
Bases:
AcousticTensorBase- Attributes:
- current_n_segments
- memory_usage_mb
- unprocessable_inputs
Methods
set_unprocessable_inputs
write_block
- property current_n_segments: int¶
- property memory_usage_mb: float¶
- set_unprocessable_inputs(unprocessable_inputs)¶
- Return type:
None
- write_block(file_indices, segment_indices, emb)¶
- Return type:
None
birdnet.acoustic.inference.core.encoding.encoding_worker module¶
- class birdnet.acoustic.inference.core.encoding.encoding_worker.EncodingWorker(session_id, backend_loader, batch_size, n_slots, rf_file_indices, rf_segment_indices, rf_audio_samples, rf_batch_sizes, rf_flags, segment_duration_samples, out_q, wkr_ring_access_lock, sem_free, sem_fill, sem_active_workers, half_precision, wkr_stats_queue, logging_queue, logging_level, device, cancel_event, prd_all_done_event, start_signal, finish_signal, end_event)¶
Bases:
WorkerBaseMethods
__call__()Call self as a function.
run_main
run_main_loop