Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions birdnet_analyzer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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'.",
Comment on lines +891 to +895
)
parser.add_argument(
"--model_save_mode",
Expand Down
2 changes: 1 addition & 1 deletion birdnet_analyzer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
9 changes: 5 additions & 4 deletions birdnet_analyzer/train/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
Loading