Choose the starting step and noise the input for image-to-image
Why it matters Image-to-image editing and sketch-to-image tools in diffusion pipelines rely on this strength logic.
Image-to-image generation does not start from pure noise. It noises the input image part of the way, then runs only the remaining denoising steps. The strength setting decides how far.
Write img2img_start(x0, timesteps, alpha_bar, strength, noise). timesteps is the sampler's list in denoising order (largest first), length N. alpha_bar is indexable by timestep. Let n_used = min(int(N * strength), N) and used = the LAST n_used entries of timesteps. If n_used is 0, return ([], x0 as an array). Otherwise with t0 = used[0], x = sqrt(alpha_bar[t0]) * x0 + sqrt(1 - alpha_bar[t0]) * noise. Return (used as a list, x).
def img2img_start(x0, timesteps, alpha_bar, strength, noise)Example
img2img_start([1.0], [3, 2, 1, 0], [0.9, 0.7, 0.5, 0.2], 0.5, [1.0]) gives ([1, 0], array([1.3844])).
Understand the idea
Text-to-image starts from pure noise and runs every denoising step. Image-to-image starts from your picture instead: noise it partway, then let the model denoise from there. Strength controls how much of the original survives. Strength 1 noises all the way and ignores the input; strength 0.3 adds a little noise and runs only the last 30% of the steps, so the layout of the input is kept.
Example: a 4-step schedule [3, 2, 1, 0] with strength 0.5 runs 2 steps, the last two: [1, 0]. We noise the input to timestep 1, where alpha_bar = 0.7: x = sqrt(0.7) * 1 + sqrt(0.3) * 1 = 0.837 + 0.548 = 1.384, and then denoise with steps 1 and 0.
Rule: n = min(int(N * strength), N); used = last n timesteps; x = sqrt(ab[used[0]]) x0 + sqrt(1 - ab[used[0]]) noise.
Inpainting and style-transfer pipelines reuse the same start-step logic.