From 21483f5d0731bce5aa97985e722a64bf0d7cd12c Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 1 Nov 2022 16:50:24 +1100 Subject: [PATCH] Fixes silent crash when init image too large To send the mask to the server, the UI rendered the mask onto the init image and sent the whole image. The mask was then cropped by the server. If the image was too large, the app silently failed. Maybe it exceeds the websocket size limit. Fixed by cropping the mask in the UI layer, sending only bounding-box-sized mask image data. --- backend/invoke_ai_web_server.py | 6 +----- frontend/src/features/tabs/Inpainting/util/generateMask.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/backend/invoke_ai_web_server.py b/backend/invoke_ai_web_server.py index b9fc147911..64304d395d 100644 --- a/backend/invoke_ai_web_server.py +++ b/backend/invoke_ai_web_server.py @@ -573,11 +573,7 @@ class InvokeAIWebServer: ) ) ) - # crop the mask image - cropped_mask_image = copy_image_from_bounding_box( - mask_image, **generation_parameters["bounding_box"] - ) - generation_parameters["init_mask"] = cropped_mask_image + generation_parameters["init_mask"] = mask_image totalSteps = self.calculate_real_steps( steps=generation_parameters["steps"], diff --git a/frontend/src/features/tabs/Inpainting/util/generateMask.ts b/frontend/src/features/tabs/Inpainting/util/generateMask.ts index 37b3902d94..11e4cc2f00 100644 --- a/frontend/src/features/tabs/Inpainting/util/generateMask.ts +++ b/frontend/src/features/tabs/Inpainting/util/generateMask.ts @@ -101,7 +101,7 @@ const generateMask = ( new Konva.Image({ image: image, globalCompositeOperation: 'source-out' }) ); - const maskDataURL = stage.toDataURL(); + const maskDataURL = stage.toDataURL({ ...boundingBox }); return { maskDataURL, isMaskEmpty }; };