dpm-solver
dpm-solver copied to clipboard
how to replace ddim with dpm-solver in the origin stable diffusion? (img2img)
i had tried to replace
z_enc = sampler.stochastic_encode(init_latent, torch.tensor([t_enc]*batch_size).to(device))
samples = sampler.decode(z_enc, c, t_enc, unconditional_guidance_scale=opt.scale,
unconditional_conditioning=uc)
with
noised_sample = sampler.stochastic_encode(init_latent, opt.strength)
samples, _ = sampler.sample(
opt.ddim_steps,
noised_sample.shape[0],
noised_sample.shape[1:],
conditioning=c,
unconditional_guidance_scale=opt.scale,
unconditional_conditioning=uc,
method="multistep",
order=2,
lower_order_final=False,
t_start=sampler.ratio_to_time(opt.strength),
x_T=noised_sample,
)
but the results don' well.(same step not better than ddim) . Is there any other better way?
have you got any solution?
Hey, I think you have to replace the opt.strength with 1-opt.strength in your codes (two places).
e.g. when the strength of input image is 0, it's equivalent to a text2img generation (start from pure noise), then the input time t for stochastic_encode should be 1; and when you set the opt.strength=1, the output should be same to the input image.
PS: I still find that the output of img2img with dpm solver different from ddim. Could you also compare these two methods, if you are able to make dpm solver work?