Add BirdNET-Geomodel 3.0#41
Conversation
| backend: MODEL_BACKENDS, | ||
| precision: MODEL_PRECISIONS, | ||
| lang: MODEL_LANGUAGES, | ||
| lang: MODEL_LANGUAGES_V2_4, |
There was a problem hiding this comment.
should be version inspecific as the method name suggests -> use MODEL_LANGUAGES
There was a problem hiding this comment.
There is no general MODEL_LANGUAGES anymore, language is now tied to the model version, I'll use str instead.
| pytest.skip("litert library is not available") | ||
|
|
||
|
|
||
| def ensure_tf_2_19_or_2_18() -> None: |
There was a problem hiding this comment.
Is it not possible to support TF >= 2.18? If not, it would be value to keep a notice in the README that just exact versions 2.18/19 are supported. Because I got: "RuntimeError: The geo model v3.0 TF backend requires TensorFlow 2.18 or 2.19, but '2.21.0' is installed".
There was a problem hiding this comment.
The geomodel tflite export currently only runs with TF 2.18 and 2.19 sadly ...
Will make a note in the README to use pb instead
| "zh", | ||
| ] | ||
|
|
||
| MODEL_LANGUAGES = MODEL_LANGUAGES_V2_4 | MODEL_LANGUAGES_V3_0 |
There was a problem hiding this comment.
Maybe it is possible to use this instead of str for typing. But it's a hassle with the Python typing validiation...
There was a problem hiding this comment.
True, you think thats better than str? I think the current implementation is coherent and this is not an improvement since values still get rejected at runtime
…into geomodel-3.0
…ncompatible tf version
… (not compatible)
There was a problem hiding this comment.
Pull request overview
This PR adds support for the BirdNET GeoModel v3.0 across the public loader API, including new TF/PB backends and updated geo inference behavior for “year-round” predictions (when week=None). It also tightens TensorFlow compatibility checks for Perch v2 and expands tests/CI support around these changes.
Changes:
- Add GeoModel v3.0 implementation (downloaders + TF/PB backends) and wire it into
model_loader(+ typing stubs). - Add “year-round” geo prediction support via backend-provided week inputs and configurable aggregation (
max/average) whenweek=None. - Add/adjust tests and CI workflow steps (log artifact upload on failures), plus Perch v2 TF version validation.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/birdnet/model_loader.pyi | Adds typed overloads for geo model v3.0 and splits language literals by model version. |
| src/birdnet/model_loader.py | Routes geo loads/custom-loads to v2.4 vs v3.0 implementations; adds TF library compatibility hook; adds Perch v2 TF version check call. |
| src/birdnet/globals.py | Introduces geo model v3.0 constants, year-round aggregation constants, and splits model languages by version. |
| src/birdnet/geo/models/v3_0/model.py | New GeoModelV3_0 + label/taxonomy + localized language-file generation. |
| src/birdnet/geo/models/v3_0/tf.py | New v3.0 TF (TFLite) downloader/backends + TF runtime compatibility checks + year-round week inputs. |
| src/birdnet/geo/models/v3_0/pb.py | New v3.0 PB downloader/backend + year-round week inputs. |
| src/birdnet/geo/models/v3_0/init.py | Adds v3.0 package init. |
| src/birdnet/geo/models/v2_4/tf.py | Implements year_round_week_inputs() for v2.4 geo TF backend. |
| src/birdnet/geo/models/v2_4/pb.py | Implements year_round_week_inputs() for v2.4 geo PB backend; minor formatting tweak. |
| src/birdnet/geo/models/v2_4/model.py | Extends predict API to accept year_round_aggregation and forwards it into the session. |
| src/birdnet/geo/inference/session.py | Implements year-round inference path when week=None with configurable aggregation. |
| src/birdnet/geo/inference/configs.py | Updates RunConfig.week to `int |
| src/birdnet/geo/inference/prediction_result.py | Makes structured-array conversion safe when there are zero predictions (default max length). |
| src/birdnet/core/backends.py | Extends VersionedGeoBackendProtocol with year_round_week_inputs(); minor formatting change in TFBackend load. |
| src/birdnet/acoustic/models/perch_v2/pb.py | Adds TF version parsing and TensorFlow >= 2.20 enforcement helper. |
| src/birdnet_tests/model_loader_py/geo/test_load_v3_0.py | Adds loader tests for geo v3.0 (TF/PB) and type/kwarg validation. |
| src/birdnet_tests/model_loader_py/geo/test_load_custom_v3_0.py | Adds custom-loader tests for geo v3.0 across TF/PB paths. |
| src/birdnet_tests/geo_models/v3_0/tf_py/test_download_geo_tf_model.py | Adds (non-collected) helper download tests for geo v3.0 TF artifacts. |
| src/birdnet_tests/geo_models/v3_0/pb_py/test_download_geo_pb_model.py | Adds (non-collected) helper download tests for geo v3.0 PB artifacts. |
| src/birdnet_tests/geo_models/v3_0/model_py/test_predict/test_geo_predict_model.py | Adds geo v3.0 prediction tests across TF/PB (and skipped LiteRT) paths. |
| src/birdnet_tests/consistency_tests/xtest_geo_v3_0_consistency.py | Adds (non-collected) consistency test harness for v3.0 across precisions/backends. |
| src/birdnet_tests/model_loader_py/acoustic/test_acoustic_load.py | Minor comment formatting tweak in timeout handling. |
| src/birdnet_tests/model_loader_py/acoustic/test_acoustic_load_perch.py | Adds TF>=2.20 test gating and a wrong-TF-version regression test for Perch v2. |
| src/birdnet_tests/acoustic_models/perch_v2/model_py/test_perch_acoustic_predict_model.py | Adds autouse fixture to skip when TF < 2.20. |
| src/birdnet_tests/acoustic_models/perch_v2/model_py/test_perch_acoustic_encode_model.py | Adds autouse fixture to skip when TF < 2.20. |
| src/birdnet_tests/helper.py | Adds TF version gating helpers and a placeholder skip for geo v3.0 LiteRT support. |
| src/birdnet_tests/backends_py/test_load_tf_model.py | Skips a flaky/behavior-changed LiteRT/TF interop test. |
| pyproject.toml | Adjusts ai-edge-litert dependency marker. |
| docs/birdnet.geo_models.v3_0.rst | Adds Sphinx autodoc page for geo v3.0 docs. |
| .github/workflows/ci.yml | Uploads .log artifacts extracted from output.log when CI fails. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MODEL_LANGUAGE_EN_US = "en_us" | ||
| MODEL_LANGUAGES = ( | ||
| Literal[ | ||
| "af", | ||
| "ar", | ||
| "cs", | ||
| "da", | ||
| "de", | ||
| "en_uk", | ||
| "en_us", | ||
| "es", | ||
| "fi", | ||
| "fr", | ||
| "hu", | ||
| "it", | ||
| "ja", | ||
| "ko", | ||
| "nl", | ||
| "no", | ||
| "pl", | ||
| "pt", | ||
| "ro", | ||
| "ru", | ||
| "sk", | ||
| "sl", | ||
| "sv", | ||
| "th", | ||
| "tr", | ||
| "uk", | ||
| "zh", | ||
| ] | ||
| | Literal["latin"] | ||
| ) | ||
| VALID_MODEL_LANGUAGES = [ | ||
| MODEL_LANGUAGES_V2_4 = Literal[ | ||
| "af", | ||
| "ar", | ||
| "cs", | ||
| "da", |
There was a problem hiding this comment.
@stefantaubert I do not see any latin label file in the app data directory. Is it safe to remove?
No description provided.