diff options
author | AUTOMATIC <16777216c@gmail.com> | 2023-01-09 11:57:47 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2023-01-09 11:57:47 +0000 |
commit | d4fd2418efb0986a8226add0b800fb5c73ffb58c (patch) | |
tree | fb9e9f66ce779f87e0d783e8e00a7f1fbbdc60e1 /modules/processing.py | |
parent | 8850fc23b6e8a8e210bdfe4aade81516fb5770f3 (diff) | |
download | stable-diffusion-webui-gfx803-d4fd2418efb0986a8226add0b800fb5c73ffb58c.tar.gz stable-diffusion-webui-gfx803-d4fd2418efb0986a8226add0b800fb5c73ffb58c.tar.bz2 stable-diffusion-webui-gfx803-d4fd2418efb0986a8226add0b800fb5c73ffb58c.zip |
add an option to use old hiresfix width/height behavior
add a visual effect to inactive hires fix elements
Diffstat (limited to 'modules/processing.py')
-rw-r--r-- | modules/processing.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/modules/processing.py b/modules/processing.py index 1d23b15f..f04a0e1e 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -687,6 +687,18 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: return res
+def old_hires_fix_first_pass_dimensions(width, height):
+ """old algorithm for auto-calculating first pass size"""
+
+ desired_pixel_count = 512 * 512
+ actual_pixel_count = width * height
+ scale = math.sqrt(desired_pixel_count / actual_pixel_count)
+ width = math.ceil(scale * width / 64) * 64
+ height = math.ceil(scale * height / 64) * 64
+
+ return width, height
+
+
class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
sampler = None
@@ -703,16 +715,26 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing): self.hr_upscale_to_y = hr_resize_y
if firstphase_width != 0 or firstphase_height != 0:
- print("firstphase_width/firstphase_height no longer supported; use hr_scale", file=sys.stderr)
- self.hr_scale = self.width / firstphase_width
+ self.hr_upscale_to_x = self.width
+ self.hr_upscale_to_y = self.height
self.width = firstphase_width
self.height = firstphase_height
self.truncate_x = 0
self.truncate_y = 0
+ self.applied_old_hires_behavior_to = None
def init(self, all_prompts, all_seeds, all_subseeds):
if self.enable_hr:
+ if opts.use_old_hires_fix_width_height and self.applied_old_hires_behavior_to != (self.width, self.height):
+ self.hr_resize_x = self.width
+ self.hr_resize_y = self.height
+ self.hr_upscale_to_x = self.width
+ self.hr_upscale_to_y = self.height
+
+ self.width, self.height = old_hires_fix_first_pass_dimensions(self.width, self.height)
+ self.applied_old_hires_behavior_to = (self.width, self.height)
+
if self.hr_resize_x == 0 and self.hr_resize_y == 0:
self.extra_generation_params["Hires upscale"] = self.hr_scale
self.hr_upscale_to_x = int(self.width * self.hr_scale)
|