runners
birdnet_stm32.models.runners
¶
Inference runners for Keras and TFLite models.
Provides a uniform predict(x_batch) interface for both model formats, enabling the evaluation pipeline to be agnostic to the model type.
KerasRunner
¶
Thin wrapper for a Keras model to standardize batch prediction.
Source code in birdnet_stm32/models/runners.py
__init__(model)
¶
Initialize with a loaded Keras model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Loaded Keras model (compiled=False is fine). |
required |
Source code in birdnet_stm32/models/runners.py
predict(x_batch)
¶
Run a forward pass on a batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_batch
|
ndarray
|
Input batch in the model's expected shape and dtype. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Model outputs [B, C] as float32. |
Source code in birdnet_stm32/models/runners.py
TFLiteRunner
¶
TFLite model runner using the builtin interpreter (no delegates).
Source code in birdnet_stm32/models/runners.py
__init__(model_path)
¶
Initialize with a TFLite model file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Path to a .tflite model file. |
required |
Source code in birdnet_stm32/models/runners.py
predict(x_batch)
¶
Run a forward pass on a batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_batch
|
ndarray
|
Input batch in the model's expected shape and dtype. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Model outputs [B, C] as float32. |
Source code in birdnet_stm32/models/runners.py
load_model_runner(model_path)
¶
Load a .keras or .tflite model and return a runner with predict().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
str
|
Path to a saved model (.keras or .tflite). |
required |
Returns:
| Type | Description |
|---|---|
|
KerasRunner or TFLiteRunner instance. |