Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The results are blurry images with vanilla ddpm #52

Open
AidenLsz opened this issue Mar 9, 2024 · 2 comments
Open

The results are blurry images with vanilla ddpm #52

AidenLsz opened this issue Mar 9, 2024 · 2 comments

Comments

@AidenLsz
Copy link

AidenLsz commented Mar 9, 2024

Dear authors,
Thank you for generously sharing your great work!
I used dpm-solver to accelerate vanilla ddpm for image purification.And if I set timesteps OF DDPM as 500,with my pretrained model,I can gradually reverse the image to one that's close to the original one:
image
However,when I used dpm-solver,the results are blurry:
image

Settings:
512*512 celebahq;
betas are from 0.0001 to 01004004 with 500 steps,so x_start=1,x_end=1/500;
self.model:the same one in your responsitory,whose path is "dpm-solver/examples/ddpm_and_guided-diffusion/models
/diffusion.py"

noise_schedule = NoiseScheduleVP(schedule='discrete', betas=self.betas) model_fn = model_wrapper( self.model, noise_schedule, model_type="noise", model_kwargs={}, guidance_type="uncond" )

self.dpm_solver = DPM_Solver(model_fn, noise_schedule, algorithm_type="dpmsolver++") x_sample = self.dpm_solver.sample( x, steps=20, order=3, skip_type="time_uniform", method="singlestep"
I tried singlestep,multistep,steps ranging [10,1000],orders as 1,2 or 3.Nothing worked.
Thanks for your kind help!

@LuChengTHU
Copy link
Owner

What's the training loss of your model?

@AidenLsz
Copy link
Author

What's the training loss of your model?

Thanks for your quick response!
The loss is the squared difference between the predicted noise and the real noise added in step t-1;
I used the pretrained model of this repo,which claims that it's a copy from SDEdit.So it should be trained with code below from this PyTorch implementation for training the model according to its readme:(comments are added by me)

def noise_estimation_loss(model,
                          x0: torch.Tensor, //image used for training
                          t: torch.LongTensor, //timestep
                          e: torch.Tensor,// random noise having shape of x0
                          b: torch.Tensor, //self.betas
keepdim=False):
    a = (1-b).cumprod(dim=0).index_select(0, t).view(-1, 1, 1, 1)
    x = x0 * a.sqrt() + e * (1.0 - a).sqrt()// image after adding t steps of noise
    output = model(x, t.float()) //the predicted noise added by step t-1
    if keepdim:
        return (e - output).square().sum(dim=(1, 2, 3))//the difference between predicted noise and real noise
    else:
        return (e - output).square().sum(dim=(1, 2, 3)).mean(dim=0)

loss_registry = {
    'simple': noise_estimation_loss,
}

ps:I found this copy in SDEdit‘s issuse because the pretrained model in it cannot be accessed,and it worked fine in vanilla DDPM as a NOISE PREDICTION MODEL.
Thanks again for your kind help!It means a lot to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants