From 09888c4be370f7a0bc0664a27571fe06a54a5b83 Mon Sep 17 00:00:00 2001 From: Josef Haupt Date: Mon, 6 Jul 2026 11:36:23 +0200 Subject: [PATCH] Fix model_formats arg missing in cli --- birdnet_analyzer/cli.py | 11 ++++++----- birdnet_analyzer/config.py | 2 +- birdnet_analyzer/train/core.py | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/birdnet_analyzer/cli.py b/birdnet_analyzer/cli.py index 3a9ca9005..de08dddcb 100644 --- a/birdnet_analyzer/cli.py +++ b/birdnet_analyzer/cli.py @@ -9,7 +9,7 @@ MODEL_LANGUAGES, ) -from birdnet_analyzer.config import AUTOTUNE_METRICS +from birdnet_analyzer.config import AUTOTUNE_METRICS, TRAINED_MODEL_OUTPUT_FORMATS SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) ASCII_LOGO = r""" @@ -888,10 +888,11 @@ def train_parser(): help="Upsampling mode.", ) parser.add_argument( - "--model_format", - default="tflite", - choices=["tflite", "raven", "both"], - help="Model output format.", + "--model_formats", + nargs="+", + default=["tflite"], + choices=get_args(TRAINED_MODEL_OUTPUT_FORMATS), + help="Model output format(s). One or more of 'tflite', 'raven', 'detached'.", ) parser.add_argument( "--model_save_mode", diff --git a/birdnet_analyzer/config.py b/birdnet_analyzer/config.py index 025f21abb..5cb39e5c3 100644 --- a/birdnet_analyzer/config.py +++ b/birdnet_analyzer/config.py @@ -33,6 +33,6 @@ SAMPLE_CROP_MODES = Literal["center", "first", "segments", "smart"] NON_EVENT_CLASSES: list[str] = ["noise", "other", "background", "silence"] UPSAMPLING_MODES = Literal["repeat", "mean", "smote"] -TRAINED_MODEL_OUTPUT_FORMATS = Literal["tflite", "raven", "both"] +TRAINED_MODEL_OUTPUT_FORMATS = Literal["tflite", "raven", "detached"] TRAINED_MODEL_SAVE_MODES = Literal["replace", "append"] AUTOTUNE_METRICS = Literal["val_loss", "val_AUPRC", "val_AUROC"] diff --git a/birdnet_analyzer/train/core.py b/birdnet_analyzer/train/core.py index 975f81549..98c5ce2ff 100644 --- a/birdnet_analyzer/train/core.py +++ b/birdnet_analyzer/train/core.py @@ -32,7 +32,8 @@ def train( mixup: bool = False, upsampling_ratio: float = 0.0, upsampling_mode: UPSAMPLING_MODES = "repeat", - model_format: TRAINED_MODEL_OUTPUT_FORMATS = "tflite", + model_formats: list[TRAINED_MODEL_OUTPUT_FORMATS] + | TRAINED_MODEL_OUTPUT_FORMATS = "tflite", model_save_mode: TRAINED_MODEL_SAVE_MODES = "replace", save_cache_to: str | None = None, threads: int = 1, @@ -80,8 +81,8 @@ def train( classes. Defaults to 0.0. upsampling_mode (Literal["repeat", "mean", "smote"], optional): Mode for upsampling. Defaults to "repeat". - model_format (Literal["tflite", "raven", "both"], optional): Format to save the - trained model. Defaults to "tflite". + model_formats (list[Literal["tflite", "raven", "detached"]] | str, optional): + One or more formats to save the trained model. Defaults to "tflite". model_save_mode (Literal["replace", "append"], optional): Save mode for the model. Defaults to "replace". save_cache_to (str | None, optional): Path to save the cache file. @@ -128,7 +129,7 @@ def train( mixup=mixup, upsampling_ratio=upsampling_ratio, upsampling_mode=upsampling_mode, - model_format=model_format, + model_formats=model_formats, model_save_mode=model_save_mode, save_cache_to=save_cache_to, threads=threads,