force inpaint

This commit is contained in:
Vladimir Mandic
2023-11-22 12:28:35 -05:00
parent d660b288f8
commit fd9d747a47
3 changed files with 2 additions and 11 deletions
-4
View File
@@ -214,10 +214,8 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro
p.mask = TF.to_pil_image(torch.ones_like(TF.to_tensor(p.init_images[0]))).convert("L")
width = 8 * math.ceil(p.init_images[0].width / 8)
height = 8 * math.ceil(p.init_images[0].height / 8)
# option-1: use images as inputs
task_args = {"image": p.init_images, "mask_image": p.mask, "strength": p.denoising_strength, "height": height, "width": width}
""" # option-2: preprocess images into latents using diffusers
vae_scale_factor = 2 ** (len(model.vae.config.block_out_channels) - 1)
image_processor = diffusers.image_processor.VaeImageProcessor(vae_scale_factor=vae_scale_factor)
@@ -226,7 +224,6 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro
mask_image = mask_processor.preprocess(p.mask, width=width, height=height)
task_args = {"image": p.init_images, "mask_image": p.mask, "strength": p.denoising_strength, "height": height, "width": width}
"""
""" # option-2: manually assemble masked image latents
masked_image_latents = []
mask_image = TF.to_tensor(p.mask)
@@ -237,7 +234,6 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro
masked_image_latents = torch.stack(masked_image_latents, dim=0).to(shared.device)
task_args = {"image": p.init_images, "mask_image": mask_image, "masked_image_latents": masked_image_latents, "strength": p.denoising_strength, "height": height, "width": width}
"""
if model.__class__.__name__ == 'LatentConsistencyModelPipeline' and hasattr(p, 'init_images') and len(p.init_images) > 0:
init_latents = [vae_encode(image, model=shared.sd_model, full_quality=p.full_quality).squeeze(dim=0) for image in p.init_images]
init_latent = torch.stack(init_latents, dim=0).to(shared.device)