openai / improved-diffusion

Release for Improved Denoising Diffusion Probabilistic Models
MIT License
3.15k stars 479 forks source link

1D images #70

Open JesseWiers opened 1 year ago

JesseWiers commented 1 year ago

Has anyone made the code work for 1D images? I changed in_channels and out_channels to 1 in the creation of the model in script_util.py and removed the conversion to RGB in image_datasets.py. Afterwards, I have been training a model for 80 000 iterations on 14 000 black-white medical images with a batch size of 8 and minibatch of 1 but the samples are pure noise.

ykcheng9966 commented 1 year ago

hi,bro!have you solved this problem? Would you mind sharing the parameters for training 1D images?

leffff commented 11 months ago

Please share the hyper parameters! That would be helpful

leffff commented 11 months ago

hi,bro!have you solved this problem? Would you mind sharing the parameters for training 1D images?

So well I managed to start 1D U-Net

model = UNetModel(
    in_channels=198, # should be equal to num_features (input features) 
    dims=1, #this states, that we are using 1D U-Net
    model_channels=256, # inner model features
    out_channels=198, # should be equal to num_features (input features) 
    num_res_blocks=10, # idk
    attention_resolutions=("16",) # idk
)

x_0 = torch.rand(23, 64, 198) # our input [batch_size, num_atoms, num_features]
#num_atoms should be a 2 to some power
t = torch.rand(23) # our time [batch_size]

model(
    x=x_0, 
    timesteps=t, 
).shape # torch.Size([23, 64, 198]), which matches x.shape torch.Size([23, 64, 198])
zjgt commented 4 months ago

Hi, leffff, could you share more about your codes? I also started training with black and white images. I got a write_line error with the default hyperparameters. Also, how is the diffusion model work compared to StyleGAN?