stke9 / SliceGAN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RuntimeError: Given groups=1, weight of size [64, 3, 4, 4], expected input[32, 238, 64, 64] to have 3 channels, but got 238 channels instead

linbinbin92 opened this issue · comments

Dear Steve,

as I just tested a arbitary image trying to generate a 3D structure using your SliceGAN,

I encountered the following issue:

File "run_slicegan.py", line 52, in
model.train(Project_path, image_type, data_type, data_path, netD, netG, img_channels, img_size, z_channels, scale_factor)
File "/work/scratch/ac01asac/SliceGAN/slicegan/model.py", line 104, in train
out_real = netD(real_data).view(-1).mean()
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1015, in _call_impl
return forward_call(*input, **kwargs)
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 150, in forward
return self.module(*inputs, **kwargs)
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1015, in call_impl
return forward_call(*input, **kwargs)
File "/work/scratch/ac01asac/SliceGAN/slicegan/networks.py", line 55, in forward
x = F.relu
(conv(x))
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1015, in _call_impl
return forward_call(*input, **kwargs)
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 443, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/home/ac01asac/.local/lib/python3.8/site-packages/torch/nn/modules/conv.py", line 439, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 3, 4, 4], expected input[32, 238, 64, 64] to have 3 channels, but got 238 channels instead.

  • seems that there is some compatibility issue. I used the following image, and specified the type and name as requested in the run_slicegan.py file.

  • Would you also provide your NMC.tif file in the repo just to give a test?

img

commented

Hi there,

I would expect the error means that ‘image_type’ or ‘data_type’ are not set to ‘colour’ (it’s trying to assign an individual phase for every colour, hence the 238 channels instead of 3!)… Anyway, I have uploaded the NMC.tif file, and as mentioned in the paper n-phase materials tend to work much better so I would suggest starting there 😊

Hi there,

I would expect the error means that ‘image_type’ or ‘data_type’ are not set to ‘colour’ (it’s trying to assign an individual phase for every colour, hence the 238 channels instead of 3!)… Anyway, I have uploaded the NMC.tif file, and as mentioned in the paper n-phase materials tend to work much better so I would suggest starting there 😊

Hi, thanks for the quick reply.

  • I tried as you suggested by setting both the ‘image_type’ and ‘data_type’ to 'colour'. Previously I only had 'image_type' to 'colour' it lead to the mentioned error. now it works fine :)
    and thanks for uploading the file, it works fine as well !