Spaces:
Runtime error
Runtime error
Fixed remove bb box and extended mask
Browse files
app.py
CHANGED
@@ -241,6 +241,15 @@ def lama_cleaner_process(image, mask):
|
|
241 |
image = Image.open(io.BytesIO(numpy_to_bytes(res_np_img, 'png')))
|
242 |
return image
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_threshold, text_threshold,
|
245 |
iou_threshold, inpaint_mode, mask_source_radio, remove_mode, remove_mask_extend):
|
246 |
|
@@ -392,7 +401,8 @@ def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_t
|
|
392 |
except:
|
393 |
remove_mask_extend = 10
|
394 |
mask_pil_exp = mask_extend(copy.deepcopy(mask_pil).convert("RGB"),
|
395 |
-
box_convert(torch.tensor(boxes_filt_ori_array[i]), in_fmt="cxcywh", out_fmt="xyxy").numpy(),
|
|
|
396 |
extend_pixels=remove_mask_extend, useRectangle=useRectangle)
|
397 |
mask_imgs.append(mask_pil_exp)
|
398 |
mask_pil = mix_masks(mask_imgs)
|
|
|
241 |
image = Image.open(io.BytesIO(numpy_to_bytes(res_np_img, 'png')))
|
242 |
return image
|
243 |
|
244 |
+
def xywh_to_xyxy(box, sizeW, sizeH):
|
245 |
+
if isinstance(box, list):
|
246 |
+
box = torch.Tensor(box)
|
247 |
+
box = box * torch.Tensor([sizeW, sizeH, sizeW, sizeH])
|
248 |
+
box[:2] -= box[2:] / 2 # top left corner
|
249 |
+
box[2:] += box[:2] # bottom right corner
|
250 |
+
box = box.numpy()
|
251 |
+
return box
|
252 |
+
|
253 |
def run_anything_task(input_image, text_prompt, task_type, inpaint_prompt, box_threshold, text_threshold,
|
254 |
iou_threshold, inpaint_mode, mask_source_radio, remove_mode, remove_mask_extend):
|
255 |
|
|
|
401 |
except:
|
402 |
remove_mask_extend = 10
|
403 |
mask_pil_exp = mask_extend(copy.deepcopy(mask_pil).convert("RGB"),
|
404 |
+
# box_convert(torch.tensor(boxes_filt_ori_array[i]), in_fmt="cxcywh", out_fmt="xyxy").numpy(),
|
405 |
+
xywh_to_xyxy(torch.tensor(boxes_filt_ori_array[i]), size[0], size[1]),
|
406 |
extend_pixels=remove_mask_extend, useRectangle=useRectangle)
|
407 |
mask_imgs.append(mask_pil_exp)
|
408 |
mask_pil = mix_masks(mask_imgs)
|