From bff96b76bb382e4e2005af2abb51228905ad2616 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Sun, 31 Dec 2023 19:58:07 +0530 Subject: [PATCH] qr reference: always need to reposition, even if the user did not moved/scaled the image --- recipes/QRCodeGenerator.py | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/recipes/QRCodeGenerator.py b/recipes/QRCodeGenerator.py index 983c3a2c9..d044737cd 100644 --- a/recipes/QRCodeGenerator.py +++ b/recipes/QRCodeGenerator.py @@ -483,28 +483,20 @@ def run(self, state: dict) -> typing.Iterator[str | None]: request.selected_controlnet_model = [request.selected_controlnet_model] init_images = [image] * len(request.selected_controlnet_model) if request.image_prompt: - if ( - request.image_prompt_scale != 1.0 - or request.image_prompt_pos_x != 0.5 - or request.image_prompt_pos_y != 0.5 - ): - # we only need to reposition if the user moved/scaled the image - image_prompt = bytes_to_cv2_img( - requests.get(request.image_prompt).content - ) - repositioned_image_prompt, _ = reposition_object( - orig_img=image_prompt, - orig_mask=image_prompt, - out_size=(request.output_width, request.output_height), - out_obj_scale=request.image_prompt_scale, - out_pos_x=request.image_prompt_pos_x, - out_pos_y=request.image_prompt_pos_y, - color=255, - ) - request.image_prompt = upload_file_from_bytes( - "repositioned_image_prompt.png", - cv2_img_to_bytes(repositioned_image_prompt), - ) + image_prompt = bytes_to_cv2_img(requests.get(request.image_prompt).content) + repositioned_image_prompt, _ = reposition_object( + orig_img=image_prompt, + orig_mask=image_prompt, + out_size=(request.output_width, request.output_height), + out_obj_scale=request.image_prompt_scale, + out_pos_x=request.image_prompt_pos_x, + out_pos_y=request.image_prompt_pos_y, + color=255, + ) + request.image_prompt = upload_file_from_bytes( + "repositioned_image_prompt.png", + cv2_img_to_bytes(repositioned_image_prompt), + ) init_images += [request.image_prompt] * len( request.image_prompt_controlnet_models )