diff --git a/modules/processing.py b/modules/processing.py index 536dd97bf..b519ec868 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -1080,6 +1080,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing): samples = samples[:, :, self.truncate_y//2:samples.shape[2]-(self.truncate_y+1)//2, self.truncate_x//2:samples.shape[3]-(self.truncate_x+1)//2] noise = create_random_tensors(samples.shape[1:], seeds=seeds, subseeds=subseeds, subseed_strength=subseed_strength, p=self) modules.sd_models.apply_token_merging(self.sd_model, self.get_token_merging_ratio(for_hr=True)) + hypertile_set(self, hr=True) samples = self.sampler.sample_img2img(self, samples, noise, conditioning, unconditional_conditioning, steps=self.hr_second_pass_steps or self.steps, image_conditioning=image_conditioning) modules.sd_models.apply_token_merging(self.sd_model, self.get_token_merging_ratio()) else: diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index ab4bb6f70..f8c70e595 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -14,6 +14,7 @@ import modules.taesd.sd_vae_taesd as sd_vae_taesd import modules.images as images from modules.processing import StableDiffusionProcessing import modules.prompt_parser_diffusers as prompt_parser_diffusers +from modules.sd_hijack_hypertile import hypertile_set def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_prompts): @@ -256,6 +257,7 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro pass # shared.log.debug(f'Diffuser not supported: pipeline={pipeline.__class__.__name__} task={sd_models.get_diffusers_task(model)} arg={arg}') # shared.log.debug(f'Diffuser pipeline: {pipeline.__class__.__name__} possible={possible}') + hypertile_set(p, hr=hasattr(p, 'init_images') and len(p.init_images) > 0) clean = args.copy() clean.pop('callback', None) clean.pop('callback_steps', None) diff --git a/modules/sd_hijack_hypertile.py b/modules/sd_hijack_hypertile.py index 4ab38f986..eca700e7a 100644 --- a/modules/sd_hijack_hypertile.py +++ b/modules/sd_hijack_hypertile.py @@ -90,7 +90,7 @@ def split_attention(layer: nn.Module, tile_size: int=256, min_tile_size: int=256 width = 8 * w max_w = max(max_w, w) reset_nws() - down_ratio = height // 8 // h + down_ratio = max(height // 8 // h, 1) curr_depth = round(math.log(down_ratio, 2)) # scale-up the tile-size the deeper we go nh = max(1, nh // down_ratio) @@ -166,9 +166,9 @@ def context_hypertile_unet(p): return split_attention(unet, tile_size=shared.opts.hypertile_unet_tile, min_tile_size=128, swap_size=1) -def hypertile_set(p): +def hypertile_set(p, hr=False): global height, width, error_reported, reset_needed # pylint: disable=global-statement error_reported = False - height=p.height - width=p.width + height=p.height if not hr else p.hr_upscale_to_y + width=p.width if not hr else p.hr_upscale_to_x reset_needed = True