diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 254f94d72..fc64724ac 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -37,6 +37,13 @@ def process_diffusers(p: processing.StableDiffusionProcessing): for j in range(len(decoded)): images.save_image(decoded[j], path=p.outpath_samples, basename="", seed=p.seeds[i], prompt=p.prompts[i], extension=shared.opts.samples_format, info=info, p=p, suffix=suffix) + def apply_circular(enable): + try: + for layer in [layer for layer in shared.sd_model.unet.modules() if type(layer) is torch.nn.Conv2d]: + layer.padding_mode = 'circular' if enable else 'zeros' + except Exception as e: + debug(f"Diffusers tiling failed: {e}") + def diffusers_callback_legacy(step: int, timestep: int, latents: typing.Union[torch.FloatTensor, np.ndarray]): if isinstance(latents, np.ndarray): # latents from Onnx pipelines is ndarray. latents = torch.from_numpy(latents) @@ -159,6 +166,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing): def set_pipeline_args(model, prompts: list, negative_prompts: list, prompts_2: typing.Optional[list]=None, negative_prompts_2: typing.Optional[list]=None, desc:str='', **kwargs): t0 = time.time() + apply_circular(p.tiling) if hasattr(model, "set_progress_bar_config"): model.set_progress_bar_config(bar_format='Progress {rate_fmt}{postfix} {bar} {percentage:3.0f}% {n_fmt}/{total_fmt} {elapsed} {remaining} ' + '\x1b[38;5;71m' + desc, ncols=80, colour='#327fba') args = {} diff --git a/modules/ui_sections.py b/modules/ui_sections.py index 7a958399c..2d099eb4f 100644 --- a/modules/ui_sections.py +++ b/modules/ui_sections.py @@ -115,7 +115,7 @@ def create_advanced_inputs(tab): with gr.Row(): full_quality = gr.Checkbox(label='Full quality', value=True, elem_id=f"{tab}_full_quality") restore_faces = gr.Checkbox(label='Face restore', value=False, visible=len(shared.face_restorers) > 1, elem_id=f"{tab}_restore_faces") - tiling = gr.Checkbox(label='Tiling', value=False, elem_id=f"{tab}_tiling", visible=shared.backend == shared.Backend.ORIGINAL) + tiling = gr.Checkbox(label='Tiling', value=False, elem_id=f"{tab}_tiling", visible=True) return cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, diffusers_sag_scale, cfg_end, full_quality, restore_faces, tiling def create_correction_inputs(tab):