Skip to content

Add BirdNET-Geomodel 3.0#41

Open
Josef-Haupt wants to merge 19 commits into
mainfrom
geomodel-3.0
Open

Add BirdNET-Geomodel 3.0#41
Josef-Haupt wants to merge 19 commits into
mainfrom
geomodel-3.0

Conversation

@Josef-Haupt
Copy link
Copy Markdown
Member

No description provided.

Comment thread src/birdnet/model_loader.py
Comment thread src/birdnet/model_loader.py Outdated
Comment thread src/birdnet/model_loader.py Outdated
Comment thread src/birdnet/model_loader.py Outdated
backend: MODEL_BACKENDS,
precision: MODEL_PRECISIONS,
lang: MODEL_LANGUAGES,
lang: MODEL_LANGUAGES_V2_4,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be version inspecific as the method name suggests -> use MODEL_LANGUAGES

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no general MODEL_LANGUAGES anymore, language is now tied to the model version, I'll use str instead.

Comment thread src/birdnet/model_loader.pyi
Comment thread src/birdnet/model_loader.pyi
Copy link
Copy Markdown
Member

@stefantaubert stefantaubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Comment thread src/birdnet/geo/inference/session.py Outdated
pytest.skip("litert library is not available")


def ensure_tf_2_19_or_2_18() -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/birdnet/globals.py
"zh",
]

MODEL_LANGUAGES = MODEL_LANGUAGES_V2_4 | MODEL_LANGUAGES_V3_0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is possible to use this instead of str for typing. But it's a hassle with the Python typing validiation...

Copy link
Copy Markdown
Member Author

@Josef-Haupt Josef-Haupt May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@stefantaubert stefantaubert changed the title Add BirdNET-Gemodel 3.0 Add BirdNET-Geomodel 3.0 May 10, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 65.04854% with 180 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/birdnet/geo/models/v3_0/model.py 55.40% 59 Missing and 7 partials ⚠️
src/birdnet/geo/models/v3_0/tf.py 64.56% 41 Missing and 4 partials ⚠️
src/birdnet/geo/models/v3_0/pb.py 68.67% 22 Missing and 4 partials ⚠️
src/birdnet/model_loader.py 71.64% 8 Missing and 11 partials ⚠️
src/birdnet/acoustic/models/perch_v2/pb.py 68.42% 5 Missing and 1 partial ⚠️
src/birdnet/utils/helper.py 70.58% 4 Missing and 1 partial ⚠️
src/birdnet/geo/inference/configs.py 72.72% 1 Missing and 2 partials ⚠️
src/birdnet/geo/models/v2_4/pb.py 40.00% 3 Missing ⚠️
src/birdnet/core/base.py 0.00% 0 Missing and 2 partials ⚠️
src/birdnet/geo/inference/session.py 88.23% 1 Missing and 1 partial ⚠️
... and 3 more
Files with missing lines Coverage Δ
src/birdnet/acoustic/inference/configs.py 69.27% <ø> (ø)
.../birdnet/acoustic/inference/core/input_analyzer.py 81.98% <ø> (ø)
...tic/inference/core/prediction/prediction_tensor.py 100.00% <ø> (ø)
src/birdnet/acoustic/models/perch_v2/model.py 69.41% <ø> (ø)
src/birdnet/acoustic/models/v2_4/model.py 87.35% <ø> (ø)
src/birdnet/geo/models/v2_4/model.py 93.02% <ø> (ø)
src/birdnet/globals.py 100.00% <100.00%> (ø)
src/birdnet/utils/logging_utils.py 100.00% <ø> (ø)
src/birdnet/core/backends.py 59.53% <50.00%> (-0.13%) ⬇️
src/birdnet/geo/inference/prediction_result.py 56.92% <0.00%> (+1.53%) ⬆️
... and 11 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Josef-Haupt Josef-Haupt marked this pull request as ready for review May 11, 2026 20:23
Copilot AI review requested due to automatic review settings May 11, 2026 20:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) when week=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.

Comment thread docs/birdnet.geo_models.v3_0.rst Outdated
Comment thread src/birdnet/geo/models/v3_0/model.py Outdated
Comment thread pyproject.toml Outdated
Comment thread src/birdnet_tests/model_loader_py/geo/test_load_v3_0.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 66 out of 66 changed files in this pull request and generated 6 comments.

Comment thread src/birdnet/globals.py
Comment on lines 94 to +99
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",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefantaubert I do not see any latin label file in the app data directory. Is it safe to remove?

Comment thread src/birdnet/acoustic/models/v2_4/model.py Outdated
Comment thread src/birdnet/acoustic/models/perch_v2/model.py
Comment thread src/birdnet/geo/inference/session.py
Comment thread src/birdnet_tests/helper.py Outdated
Comment thread src/birdnet_tests/backends_py/test_load_tf_model.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants