From 57f1e67e074fe65ba2cded6cafb9a80acfa56afd Mon Sep 17 00:00:00 2001 From: Eugene Liu Date: Thu, 27 Apr 2023 00:49:35 +0100 Subject: [PATCH] Fix tiling 0 stride issue in parameter adapter (#2078) fix tiling 0 stride issue --- otx/algorithms/common/configs/training_base.py | 2 +- otx/algorithms/detection/configs/detection/configuration.yaml | 2 +- .../configs/instance_segmentation/configuration.yaml | 2 +- .../detection/configs/rotated_detection/configuration.yaml | 2 +- otx/algorithms/detection/utils/data.py | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/otx/algorithms/common/configs/training_base.py b/otx/algorithms/common/configs/training_base.py index 1b7032bb9b9..01225c58232 100644 --- a/otx/algorithms/common/configs/training_base.py +++ b/otx/algorithms/common/configs/training_base.py @@ -359,7 +359,7 @@ class BaseTilingParameters(ParameterGroup): description="Overlap between each two neighboring tiles.", default_value=0.2, min_value=0.0, - max_value=1.0, + max_value=0.9, affects_outcome_of=ModelLifecycle.NONE, ) diff --git a/otx/algorithms/detection/configs/detection/configuration.yaml b/otx/algorithms/detection/configs/detection/configuration.yaml index 619c7e59f22..85b4cb3b826 100644 --- a/otx/algorithms/detection/configs/detection/configuration.yaml +++ b/otx/algorithms/detection/configs/detection/configuration.yaml @@ -507,7 +507,7 @@ tiling_parameters: affects_outcome_of: TRAINING default_value: 0.2 min_value: 0.0 - max_value: 1.0 + max_value: 0.9 type: FLOAT editable: true ui_rules: diff --git a/otx/algorithms/detection/configs/instance_segmentation/configuration.yaml b/otx/algorithms/detection/configs/instance_segmentation/configuration.yaml index 16eb6cb0571..7e2f9695dd8 100644 --- a/otx/algorithms/detection/configs/instance_segmentation/configuration.yaml +++ b/otx/algorithms/detection/configs/instance_segmentation/configuration.yaml @@ -523,7 +523,7 @@ tiling_parameters: affects_outcome_of: TRAINING default_value: 0.2 min_value: 0.0 - max_value: 1.0 + max_value: 0.9 type: FLOAT editable: true ui_rules: diff --git a/otx/algorithms/detection/configs/rotated_detection/configuration.yaml b/otx/algorithms/detection/configs/rotated_detection/configuration.yaml index 8a20f17e9d1..14213c8fc26 100644 --- a/otx/algorithms/detection/configs/rotated_detection/configuration.yaml +++ b/otx/algorithms/detection/configs/rotated_detection/configuration.yaml @@ -469,7 +469,7 @@ tiling_parameters: affects_outcome_of: TRAINING default_value: 0.2 min_value: 0.0 - max_value: 1.0 + max_value: 0.9 type: FLOAT editable: true ui_rules: diff --git a/otx/algorithms/detection/utils/data.py b/otx/algorithms/detection/utils/data.py index 2eccb16d706..82b49992f9e 100644 --- a/otx/algorithms/detection/utils/data.py +++ b/otx/algorithms/detection/utils/data.py @@ -481,6 +481,10 @@ def adaptive_tile_params( tile_size = int(math.sqrt(object_area / object_tile_ratio)) tile_overlap = max_area / (tile_size**2) + if tile_overlap >= tiling_parameters.get_metadata("tile_overlap")["max_value"]: + # Use the average object area if the tile overlap is too large to prevent 0 stride. + tile_overlap = object_area / (tile_size**2) + # validate parameters are in range tile_size = max( tiling_parameters.get_metadata("tile_size")["min_value"],