Why inpainting touch original image?
import torch
from diffusers.pipelines.stable_diffusion import safety_checker
from diffusers import StableDiffusionPipeline, StableDiffusionInpaintPipeline
from compel import Compel
from PIL import Image, ImageOps

from diffusers import DPMSolverMultistepScheduler

# override
def sc(self, clip_input, images): return images, [False for i in images]
safety_checker.StableDiffusionSafetyChecker.forward = sc

pipeline = StableDiffusionInpaintPipeline.from_single_file('./majicmixRealistic_v7-inpainting.safetensors', torch_dtype = torch.float16).to('cuda')
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(pipeline.scheduler.config, algorithm_type = 'sde-dpmsolver++', use_karras_sigmas = True)
compel = Compel(tokenizer = pipeline.tokenizer, text_encoder = pipeline.text_encoder)

pipeline.enable_freeu(s1 = 0.9, s2 = 0.2, b1 = 1.2, b2 = 1.4)

prompt = 'photo++ of Luxury Loft: Sophisticated, upscale, modern interior, spacious layout, sleek design, floor-to-ceiling windows, minimalist decor, capturing a luxurious ambiance, crispy'
negative_prompt = 'ugly++, cartoon, animi, blurry++'

image = Image.open('./img.png')
mask = ImageOps.invert(Image.open('./img_mask.png'))

prompt_embeds = compel.build_conditioning_tensor(prompt)
negative_prompt_embeds = compel.build_conditioning_tensor(negative_prompt)

image = pipeline(
    image = image,
    mask_image = mask,
    prompt_embeds = prompt_embeds,
    negative_prompt_embeds = negative_prompt_embeds,
    width = 600,
    height = 960,
    num_inference_steps = 70,
    guidance_scale = 5,
    clip_skip = 2,
    strength = 1,
).images[0]

display(image)image1312×1982 114 KB
2023-11-28T10:42:25Z
original imageimg1024×1536 46.8 KB