From e4816c60da497674e20362839a04c5361f86fd61 Mon Sep 17 00:00:00 2001 From: geojenks Date: Wed, 18 Sep 2024 14:36:29 +0100 Subject: [PATCH] Changed merge algorithm to save memoery. Can now work on large (higher resolution) images --- utils_inference.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils_inference.py b/utils_inference.py index 60e1837..d3b7e81 100644 --- a/utils_inference.py +++ b/utils_inference.py @@ -181,7 +181,10 @@ def tiles_merge(tiles, stride_size, img_size, paddings): for w in range(0, w_range): h_from, h_to = h*stride_h, h*stride_h + tile_h w_from, w_to = w*stride_w, w*stride_w + tile_w - merged[:, h_from:h_to, w_from:w_to] += tiles[idx]*mask + merged[:, h_from:h_to, w_from:w_to] += tiles[0]*mask + # remove data, rather than shift on to save memory + tiles = tiles[1:,:,:,:] + print(str(idx+1) + " of " + str(h_range*w_range)) idx += 1 return merged[:, pad_top:-pad_bottom, pad_left:-pad_right]