dome272 / Diffusion-Models-pytorch

Pytorch implementation of Diffusion Models (https://arxiv.org/pdf/2006.11239.pdf)
Apache License 2.0
1.11k stars 256 forks source link

Conditional Unet using dataset with one scalar label #29

Open HangilY opened 1 year ago

HangilY commented 1 year ago

Hello,

I am PhD candidate at SNU.

Your repo helped me really good understanding DDPM.

And i want to change this code to train a image labeled by 1 scalar value.

Is there any respository or your comment that i can reference?

thank you very much.

dome272 commented 1 year ago

Hey you. By a scalar you mean a continuous value within a certain range? That's an interesting question. One thing you could try is normalizing your scalar between 0 and 1 and learn an one dimensional embedding which you multiply the scalar with. Maybe even learning 2 embeddings and linearly interpolating between these two. Or you could think of discretizing your scalar and then learning an embedding for each discrete representation. All of these should be quite easy to implement in the current codebase. Does that help?

HangilY commented 1 year ago

Thanks!

  1. Yes continuous value within a certain range.
  2. Thank you, actually i was trying to embed a one dimensional tenser with value 'c'. And the got the error "RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got torch.cuda.DoubleTensor instead (while checking arguments for embedding)" Maybe the data type is not compatible i guess. I am still working on it :D. Thanks.
  3. discretizing is also a good idea and i have tried it on GAN generative model and it was good.

Thank you it helped me :D

HangilY commented 1 year ago

Thanks Dome.

I have change the code and it's doing good so far.

I have to validate data after training but the training process is working now.

These are things that i have changed:

1) CustomDataset Loader 2) Image size 3) Embedding of Label. ( I have made a tensor dimension of t, "t = self.pos_encoding(t, self.time_dim)" and filled with a scalar label value

thanks image

awais00012 commented 9 months ago

Thanks Dome.

I have change the code and it's doing good so far.

I have to validate data after training but the training process is working now.

These are things that i have changed:

  1. CustomDataset Loader
  2. Image size
  3. Embedding of Label. ( I have made a tensor dimension of t, "t = self.pos_encoding(t, self.time_dim)" and filled with a scalar label value

thanks image

hi bro< could you pleses share it with me how you did this. i am facing this problem image

although i change the prerequisits but still stuck here it would be initiative if you help out me