From f1deb4606627fd96c43ec8527c5287e0823f5905 Mon Sep 17 00:00:00 2001 From: Otto Brinkhaus Date: Thu, 19 Oct 2023 16:57:41 +0200 Subject: [PATCH] fix: do not return empty segments --- decimer_segmentation/decimer_segmentation.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/decimer_segmentation/decimer_segmentation.py b/decimer_segmentation/decimer_segmentation.py index 8be2fa7..51fa79d 100644 --- a/decimer_segmentation/decimer_segmentation.py +++ b/decimer_segmentation/decimer_segmentation.py @@ -114,6 +114,10 @@ def segment_chemical_structures( if len(segments) > 0: segments, bboxes = sort_segments_bboxes(segments, bboxes) + segments = [segment for segment in segments + if segment.shape[0] > 0 + if segment.shape[1] > 0] + return segments @@ -235,6 +239,7 @@ def get_expanded_masks(image: np.array) -> np.array: image_array=image, mask_array=masks, max_depiction_size=size, + debug=False ) return expanded_masks