From 55eff0cebdfa90d00b832f78ccb5242dbc4e6cbc Mon Sep 17 00:00:00 2001 From: mbsantiago Date: Tue, 15 Apr 2025 20:29:29 +0100 Subject: [PATCH] Fix import error --- batdetect2/compat/params.py | 16 ++++++---------- batdetect2/targets/__init__.py | 3 +-- batdetect2/targets/labels.py | 16 ++++++++-------- batdetect2/targets/targets.py | 3 ++- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/batdetect2/compat/params.py b/batdetect2/compat/params.py index 2f9f767..ffd8500 100644 --- a/batdetect2/compat/params.py +++ b/batdetect2/compat/params.py @@ -13,11 +13,10 @@ from batdetect2.preprocess import ( ) from batdetect2.preprocess.spectrogram import get_spectrogram_resolution from batdetect2.targets import ( - HeatmapsConfig, + LabelConfig, TagInfo, TargetConfig, ) -from batdetect2.targets.labels import LabelConfig from batdetect2.train.preprocess import ( TrainPreprocessingConfig, ) @@ -77,13 +76,12 @@ def get_training_preprocessing_config( preprocessing=preprocessing, target=TargetConfig( classes=[ - TagInfo(key="class", value=class_name, label=class_name) + TagInfo(key="class", value=class_name) for class_name in params["class_names"] ], generic_class=TagInfo( key="class", value=generic, - label=generic, ), include=[ TagInfo(key="event", value=event) @@ -95,12 +93,10 @@ def get_training_preprocessing_config( ], ), labels=LabelConfig( - heatmaps=HeatmapsConfig( - position="bottom-left", - time_scale=1 / time_bin_width, - frequency_scale=1 / freq_bin_width, - sigma=params["target_sigma"], - ) + position="bottom-left", + time_scale=1 / time_bin_width, + frequency_scale=1 / freq_bin_width, + sigma=params["target_sigma"], ), ) diff --git a/batdetect2/targets/__init__.py b/batdetect2/targets/__init__.py index 03a8f8a..1a99d80 100644 --- a/batdetect2/targets/__init__.py +++ b/batdetect2/targets/__init__.py @@ -7,7 +7,6 @@ predicted class labels map back to the original tag system for interpretation. """ from batdetect2.targets.labels import ( - HeatmapsConfig, LabelConfig, generate_heatmaps, load_label_config, @@ -47,7 +46,6 @@ from batdetect2.targets.transform import ( __all__ = [ "DerivationRegistry", "DeriveTagRule", - "HeatmapsConfig", "LabelConfig", "MapValueRule", "ReplaceRule", @@ -66,6 +64,7 @@ __all__ = [ "get_class_names", "get_derivation", "get_tag_from_info", + "get_term_from_key", "individual", "load_label_config", "load_target_config", diff --git a/batdetect2/targets/labels.py b/batdetect2/targets/labels.py index 0c4bd1b..bb12b82 100644 --- a/batdetect2/targets/labels.py +++ b/batdetect2/targets/labels.py @@ -308,17 +308,17 @@ def generate_heatmaps( Notes ----- * This function expects `sound_events` to be already filtered and - transformed. + transformed. * It includes error handling to skip individual annotations that cause - issues (e.g., missing geometry, out-of-bounds coordinates, encoder - errors) allowing the rest of the clip to be processed. Warnings or - errors are logged. + issues (e.g., missing geometry, out-of-bounds coordinates, encoder + errors) allowing the rest of the clip to be processed. Warnings or + errors are logged. * The `time_scale` and `frequency_scale` parameters are crucial and must be - set according to the expectations of the specific BatDetect2 model - architecture being trained. Consult model documentation for required - units/scales. + set according to the expectations of the specific BatDetect2 model + architecture being trained. Consult model documentation for required + units/scales. * Gaussian filtering and normalization are applied only to detection and - class heatmaps, not the size heatmap. + class heatmaps, not the size heatmap. """ shape = dict(zip(spec.dims, spec.shape)) diff --git a/batdetect2/targets/targets.py b/batdetect2/targets/targets.py index 1167123..c105c42 100644 --- a/batdetect2/targets/targets.py +++ b/batdetect2/targets/targets.py @@ -51,7 +51,8 @@ class TargetConfig(BaseConfig): def get_tag_label(tag_info: TagInfo) -> str: - return tag_info.label if tag_info.label else tag_info.value + # TODO: Review this + return tag_info.value def get_class_names(classes: List[TagInfo]) -> List[str]: