Diffusion-Models-pytorch icon indicating copy to clipboard operation
Diffusion-Models-pytorch copied to clipboard

Conditional Unet using dataset with one scalar label

Open HangilY opened this issue 2 years ago • 4 comments

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.

HangilY avatar May 03 '23 23:05 HangilY

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?

dome272 avatar May 04 '23 01:05 dome272

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 avatar May 04 '23 03:05 HangilY

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

HangilY avatar May 06 '23 03:05 HangilY

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

awais00012 avatar Dec 04 '23 09:12 awais00012