From 08f1926f3051de6ce7047d191a4876d75d72cd72 Mon Sep 17 00:00:00 2001 From: AUTOMATIC1111 <16777216c@gmail.com> Date: Sun, 7 Jan 2024 20:45:24 +0300 Subject: [PATCH] repair resolution calculation for img2img --- javascript/ui.js | 4 ++-- modules/ui.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/javascript/ui.js b/javascript/ui.js index d48e13ef4..74fc38798 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -317,9 +317,9 @@ function selectCheckpoint(name) { gradioApp().getElementById('change_checkpoint').click(); } -function currentImg2imgSourceResolution(w, h) { +function currentImg2imgSourceResolution(w, h, r) { var img = gradioApp().querySelector('#mode_img2img > div[style="display: block;"] :is(img, canvas)'); - return img ? [img.naturalWidth || img.width, img.naturalHeight || img.height] : [0, 0]; + return img ? [img.naturalWidth || img.width, img.naturalHeight || img.height, r] : [0, 0, r]; } function updateImg2imgResizeToTextAfterChangingImage() { diff --git a/modules/ui.py b/modules/ui.py index 2f5be99b8..345eb5dd1 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -99,8 +99,8 @@ def calc_resolution_hires(enable, width, height, hr_scale, hr_resize_x, hr_resiz def resize_from_to_html(width, height, scale_by): - target_width = int(width * scale_by) - target_height = int(height * scale_by) + target_width = int(float(width) * scale_by) + target_height = int(float(height) * scale_by) if not target_width or not target_height: return "no image selected"