openai / improved-diffusion

Release for Improved Denoising Diffusion Probabilistic Models
MIT License
3.27k stars 487 forks source link

how to use ddim_reverse_sample? #80

Open wangrx33 opened 1 year ago

wangrx33 commented 1 year ago

I am trying to use the ddim_reverse_sample to get the noise used to generate the image. I simply replaced the ddim_sample with the ddim_reverse_sample in the ddim_sample_loop_progressive function, but it seems does not work. I got an all-255 np.array. Could anyone please help me? thanks a lot.

Sutongtong233 commented 1 year ago

I am trying to use the ddim_reverse_sample to get the noise used to generate the image. I simply replaced the ddim_sample with the ddim_reverse_sample in the ddim_sample_loop_progressive function, but it seems does not work. I got an all-255 np.array. Could anyone please help me? thanks a lot.

I have the same problem. Maybe we can discuss together. You can contact me through my email :)

ajrheng commented 1 year ago

In case this is still an issue, remember to reverse the timestep indices for reverse sampling.

indices = list(range(self.num_timesteps))#[::-1] # comment out [::-1]

The original indices in ddim_sample_loop_progressive is from T to 0. You want it from 0 to T.