From 1818a36c11b9319eddc91cb3fd8d9589d800a04c Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sat, 25 Nov 2023 15:25:47 -0600 Subject: [PATCH] fix(api): correctly handle completely black mask images --- api/onnx_web/diffusers/run.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/onnx_web/diffusers/run.py b/api/onnx_web/diffusers/run.py index 11939b02..5b159019 100644 --- a/api/onnx_web/diffusers/run.py +++ b/api/onnx_web/diffusers/run.py @@ -297,8 +297,12 @@ def run_inpaint_pipeline( logger.debug("border zero: %s", border.isZero()) full_res_inpaint = full_res_inpaint and border.isZero() if full_res_inpaint: - mask_left, mask_top, mask_right, mask_bottom = mask.getbbox() - logger.debug("mask bbox: %s", mask.getbbox()) + bbox = mask.getbbox() + if bbox is None: + bbox = (0, 0, source.width, source.height) + + logger.debug("mask bounding box: %s", bbox) + mask_left, mask_top, mask_right, mask_bottom = bbox mask_width = mask_right - mask_left mask_height = mask_bottom - mask_top # ensure we have some padding around the mask when we do the inpaint (and that the region size is even)