Closed Mirko1998 closed 1 year ago
Hey there, very nice code and a good youtube tutorial! I had a little trouble using the selfattentions with other image sizes, but this isnt the problem right now, i just commented them out and the first epoch works. But after this in: ddpm.py -> sampled_images = diffusion.sample(model, n=images.shape[0]) I get an dimension error depending of the batch size... I'm confused, may some one has an Idea, I think I have mist to change the size somewhere.. Error (Batch size 4):
Traceback (most recent call last): File "_/Sync_v01/ddpm.py", line 120, in launch() File "_/Syncv01/ddpm.py", line 117, in launch train(args) File "/Sync_v01/ddpm.py", line 99, in train sampled_images = diffusion.sample(model, n=images.shape[0]) File "_/Sync_v01/ddpm.py", line 53, in sample predictednoise = model(x, t) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(_args, kwargs) File "_/Sync_v01/modules.py", line 164, in forward x1 = self.inc(x) File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/Sync_v01/modules.py", line 75, in forward return self.doubleconv(x) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(_args, kwargs) File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/container.py", line 217, in forward input = module(input) File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward return self._conv_forward(input, self.weight, self.bias) File "***/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[1, 4, 3, 64] to have 3 channels, but got 4 channels instead
Error (Batch size 3):
Traceback (most recent call last): File "_/Sync_v01/ddpm.py", line 120, in launch() File "_/Sync_v01/ddpm.py", line 117, in launch train(args) File "***/Sync_v01/ddpm.py", line 99, in train sampled_images = diffusion.sample(model, n=images.shape[0])
Thanks everyone :)
File "_/Sync_v01/ddpm.py", line 53, in sample predictednoise = model(x, t) File "e/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/Syncv01/modules.py", line 164, in forward x1 = self.inc(x) File "**/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/Sync_v01/modules.py", line 75, in forward return self.doubleconv(x) File "**/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/container.py", line 217, in forward input = module(input) File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(_args, kwargs) File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/normalization.py", line 273, in forward return F.group_norm( File "_/anaconda3v2/lib/python3.9/site-packages/torch/nn/functional.py", line 2530, in group_norm return torch.group_norm(input, num_groups, weight, bias, eps, torch.backends.cudnn.enabled) RuntimeError: Expected weight to be a vector of size equal to the number of channels in input, but got weight of shape [64] and input of shape [64, 3, 64]
I found the error, was my fault, in one line there was an self.image_size missing. Thats why there were only a tensor of dim 3 and not 4. Thanks again for the code!
Thank you for posting that the solution was really simple! Appreciate it
Hey there, very nice code and a good youtube tutorial! I had a little trouble using the selfattentions with other image sizes, but this isnt the problem right now, i just commented them out and the first epoch works. But after this in: ddpm.py -> sampled_images = diffusion.sample(model, n=images.shape[0]) I get an dimension error depending of the batch size... I'm confused, may some one has an Idea, I think I have mist to change the size somewhere.. Error (Batch size 4):
Traceback (most recent call last): File "/Sync_v01/ddpm.py", line 120, in
launch()
File " /Sync_v01/ddpm.py", line 117, in launch
train(args)
File "/Sync_v01/ddpm.py", line 99, in train
sampled_images = diffusion.sample(model, n=images.shape[0])
File "/Sync_v01/ddpm.py", line 53, in sample
predicted_noise = model(x, t)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(args, kwargs)
File "/Sync_v01/modules.py", line 164, in forward
x1 = self.inc(x)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(args, kwargs)
File "/Sync_v01/modules.py", line 75, in forward
return self.double_conv(x)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(args, kwargs)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/container.py", line 217, in forward
input = module(input)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(args, kwargs)
File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "***/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 3, 3, 3], expected input[1, 4, 3, 64] to have 3 channels, but got 4 channels instead
Error (Batch size 3):
Traceback (most recent call last): File "/Sync_v01/ddpm.py", line 120, in
launch()
File " /Sync_v01/ddpm.py", line 117, in launch
train(args)
File "***/Sync_v01/ddpm.py", line 99, in train
sampled_images = diffusion.sample(model, n=images.shape[0])
File "/Sync_v01/ddpm.py", line 53, in sample predicted_noise = model(x, t) File "e/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/Sync_v01/modules.py", line 164, in forward x1 = self.inc(x) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/Sync_v01/modules.py", line 75, in forward return self.double_conv(x) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/container.py", line 217, in forward input = module(input) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, kwargs) File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/modules/normalization.py", line 273, in forward return F.group_norm( File "/anaconda3v2/lib/python3.9/site-packages/torch/nn/functional.py", line 2530, in group_norm return torch.group_norm(input, num_groups, weight, bias, eps, torch.backends.cudnn.enabled) RuntimeError: Expected weight to be a vector of size equal to the number of channels in input, but got weight of shape [64] and input of shape [64, 3, 64]