From efc996a0db28536d58975fc72bce5ebf9869bd08 Mon Sep 17 00:00:00 2001 From: mbsantiago Date: Mon, 10 Nov 2025 19:27:31 +0000 Subject: [PATCH] Add targets to data summary command --- src/batdetect2/cli/data.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/batdetect2/cli/data.py b/src/batdetect2/cli/data.py index 4b02d8a..f571e5c 100644 --- a/src/batdetect2/cli/data.py +++ b/src/batdetect2/cli/data.py @@ -22,6 +22,11 @@ def data(): ... type=str, help="If the dataset info is in a nested field please specify here.", ) +@click.option( + "--targets", + "targets_path", + type=click.Path(exists=True), +) @click.option( "--base-dir", type=click.Path(exists=True), @@ -30,9 +35,11 @@ def data(): ... def summary( dataset_config: Path, field: Optional[str] = None, + targets_path: Optional[Path] = None, base_dir: Optional[Path] = None, ): - from batdetect2.data import load_dataset_from_config + from batdetect2.data import compute_class_summary, load_dataset_from_config + from batdetect2.targets import load_targets base_dir = base_dir or Path.cwd() @@ -44,6 +51,15 @@ def summary( print(f"Number of annotated clips: {len(dataset)}") + if targets_path is None: + return + + targets = load_targets(targets_path) + + summary = compute_class_summary(dataset, targets) + + print(summary.to_markdown()) + @data.command() @click.argument( @@ -78,15 +94,9 @@ def convert( base_dir = base_dir or Path.cwd() - config = load_dataset_config( - dataset_config, - field=field, - ) + config = load_dataset_config(dataset_config, field=field) - dataset = load_dataset( - config, - base_dir=base_dir, - ) + dataset = load_dataset(config, base_dir=base_dir) annotation_set = data.AnnotationSet( clip_annotations=list(dataset),