From 6d77b7e21217c28f27120c9544b48b68cfc4e844 Mon Sep 17 00:00:00 2001 From: aravindhv10 Date: Wed, 3 Jul 2024 13:25:36 +0530 Subject: [PATCH 1/2] Trying to get full image if mask is empty in mask_2_box --- __init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 797404e..997fd38 100644 --- a/__init__.py +++ b/__init__.py @@ -42,9 +42,15 @@ def to_torch_image(image): def get_bounding_box(mask_input): rows = np.any(mask_input, axis=1) cols = np.any(mask_input, axis=0) - rmin, rmax = np.where(rows)[0][[0, -1]] - cmin, cmax = np.where(cols)[0][[0, -1]] - return rmin, cmin, rmax, cmax + r = np.where(rows)[0] + c = np.where(cols)[0] + + if (r.flatten().shape[0] > 0) and (c.flatten().shape[0] > 0): + rmin, rmax = r[[0, -1]] + cmin, cmax = c[[0, -1]] + return rmin, cmin, rmax, cmax + else: + return 0, 0, mask_input.shape[0] - 1, mask_input.shape[1] - 1 def extract_box_from_image(image, mask): From 4d6a17949ccf534debd81217a002885b79ca067c Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 3 Jul 2024 16:36:23 +0530 Subject: [PATCH 2/2] v4.2.1; get_bounding_box has been fixed to pass original image if no mask is found --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index 997fd38..1109368 100644 --- a/__init__.py +++ b/__init__.py @@ -3732,7 +3732,7 @@ NODE_CLASS_MAPPINGS = { } -VERSION = "4.2" +VERSION = "4.2.1" # A dictionary that contains the friendly/humanly readable titles for the nodes NODE_DISPLAY_NAME_MAPPINGS = { "tri3d-photoroom-bgremove-api": "Photoroom BG Remove" + " v" + VERSION,