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, sw_start_method, 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- 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
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
- 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- property emb_dim: int¶
Return the embedding dimensionality.
- Returns:
Number of coefficients per embedding vector.
- Return type:
int
- property embeddings: ndarray¶
Return the raw embedding tensor produced by the encoder.
- Returns:
Embeddings with shape (n_inputs, n_segments, emb_dim).
- Return type:
np.ndarray
- property embeddings_masked: ndarray¶
Return the mask that marks relevant segments across files.
- Returns:
Boolean mask of the same shape as embeddings.
- Return type:
np.ndarray
- property max_n_segments: int¶
Return the maximum segment count reserved per input.
- Returns:
Number of overlapping windows available per file.
- Return type:
int
- property memory_size_MiB: float¶
Return the total result memory usage including embeddings buffers.
- Returns:
Memory size in mebibytes.
- Return type:
float
- to_arrow_table()¶
Produce a PyArrow table that serializes each embedding with timing metadata.
- Return type:
Table- Returns:
Table containing dictionary-encoded inputs and embeddings lists.
- Return type:
pa.Table
- 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- Parameters:
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:
Array with fields for input path, start/end times, and embedding.
- Return type:
np.ndarray
- unprocessable_inputs()¶
Return the indices of inputs that could not be processed.
- Return type:
ndarray- Returns:
Boolean mask or indices for skipped inputs.
- Return type:
np.ndarray
- 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
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- copy_file_slice(file_idx, n_segments)¶
Return an independent copy of a single file’s embedding rows.
The returned arrays have shape
(1, n_segments, emb_dim)so they can back a single-file result. Copying (rather than viewing) makes the data safe to hand to another thread while this tensor keeps being written/resized.Must be called from the same thread that writes the tensor (the consumer);
n_segmentsmust not exceed the segments already written for the file.- Return type:
tuple[ndarray,ndarray]
- 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
- class birdnet.acoustic.inference.core.encoding.encoding_tensor.PrebuiltEncodingTensor(emb, emb_masked)¶
Bases:
AcousticTensorBaseMinimal tensor holder wrapping already-materialised per-file embeddings.
Used to build a single-file
AcousticFileEncodingResultfrom the slice copied out of the shared result tensor, without re-running any inference.- property memory_usage_mb: float¶
- write_block(*args, **kwargs)¶
- 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, start_method)¶
Bases:
WorkerBase