From dd5264dd14fdeedec57c87567e008b10a8fcda69 Mon Sep 17 00:00:00 2001 From: rayronvictor Date: Fri, 26 Jan 2024 07:58:57 -0300 Subject: [PATCH] fix error when run_grounded_sam find no boxes --- extras/inpaint_mask.py | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/inpaint_mask.py b/extras/inpaint_mask.py index dfcb90a9..4999f258 100644 --- a/extras/inpaint_mask.py +++ b/extras/inpaint_mask.py @@ -29,6 +29,7 @@ def generate_mask_from_image(image, mask_model, extras): if mask_model == 'sam': boxes = run_grounded_sam(Image.fromarray(image), extras['sam_prompt_text'], box_threshold=extras['box_threshold'], text_threshold=extras['text_threshold']) + boxes = np.array([[0, 0, image.shape[1], image.shape[0]]]) if len(boxes) == 0 else boxes extras['sam_prompt'] = [] for idx, box in enumerate(boxes): extras['sam_prompt'] += [{"type": "rectangle", "data": box.tolist()}]