From 9dfd562dfa74bd281b52e78503b03b2fcd87ca0c Mon Sep 17 00:00:00 2001 From: Raffaele Gaetano <raffaele.gaetano@cirad.fr> Date: Thu, 16 Nov 2023 17:01:55 +0100 Subject: [PATCH] ENH: optimizing lsgrm_light --- OBIA/segmentation.py | 8 +++++--- Workflows/operations.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/OBIA/segmentation.py b/OBIA/segmentation.py index 78973fd..cb68a62 100644 --- a/OBIA/segmentation.py +++ b/OBIA/segmentation.py @@ -15,7 +15,8 @@ from tqdm import tqdm import numpy as np # GLOBAL -node_size = 700 # size of a graph node (=pixel) in GRM +# changed from the original 700 to limit OOM multiprocessing bug +node_size = 1000 # size of a graph node (=pixel) in GRM @dataclass class LSGRMParams: @@ -76,8 +77,9 @@ def grm_process_tile(input_image, params : LSGRMParams, tile_width, tile_height, op = regionprops(seg['array'][:,:,0].astype(np.int32)) to_del = [] for o in op: - if not (tie_lines[0] <= o.bbox[0] < tie_lines[2] - and tie_lines[1] <= o.bbox[1] < tie_lines[3]): + if not (tie_lines[0] <= o.bbox[0]# < tie_lines[2] + and tie_lines[1] <= o.bbox[1]):# < tie_lines[3]): + # to_del.append(o.label) # This one to check if a potentially deleted object trespass the overlap area, # in which case it is kept. if not (2*params.margin <= o.bbox[2] < tile_height and diff --git a/Workflows/operations.py b/Workflows/operations.py index 4b97e5c..43c8f96 100644 --- a/Workflows/operations.py +++ b/Workflows/operations.py @@ -11,7 +11,7 @@ def run_segmentation(img, threshold, cw, sw , out_seg, os.makedirs(os.path.dirname(out_seg)) params = OBIA.segmentation.LSGRMParams(threshold, cw, sw, n_first_iter, margin) if light: - OBIA.segmentation.lsgrm_light(img, params, out_seg, n_proc, memory, roi, force_parallel) + OBIA.segmentation.lsgrm_light(img, params, out_seg, n_proc, memory, roi, force_parallel, remove_graph) else: OBIA.segmentation.lsgrm(img, params, out_seg, n_proc, memory, roi, remove_graph, force_parallel) return out_seg -- GitLab