Closed frandam94 closed 3 months ago
Hi @frandam94.
The error comes from the mismatching shape of the image features after going through convolution. We have to augment the images to have the shape of 2^X. Please see the code here: https://github.com/HieuPhan33/MaskGAN/blob/55b2cd3b31f3e0dd3e4c4cfcc5ae90a9faefcef6/data/base_dataset.py#L86
Depending on your original image resolution, you have to resize/pad/crop them accordingly to avoid losing too much information.
For example, adding these args to resize the image to 280x280, then crop to 256x256 when there are many background area surrounding:
--preprocess resize_and_crop --load_size 280 --crop_size 256
Thank you for the quick response. I will try this way :)
Hello, i am trying to run the test after trained my model, with this command:
python test.py --dataroot ./preprocess/processed-mr-ct --gpu_ids 0 --model mask_gan --name exp_name --dataset_mode unaligned --no_dropout --norm instance --preprocess none --Aclass A --Bclass B --netG att
but i keep getting this runtime error:
./results/exp_name/test_latest Traceback (most recent call last): File "test.py", line 75, in <module> model.test() # run inference File "/home/jovyan/NAS/T1toCT_GANS/MaskGAN/MaskGAN-master/MaskGAN-master/models/base_model.py", line 113, in test self.forward() File "/home/jovyan/NAS/T1toCT_GANS/MaskGAN/MaskGAN-master/MaskGAN-master/models/mask_gan_model.py", line 126, in forward self.fake_B, self.outputs_B, self.attentions_B, self.images_B = self.netG_A(self.real_A) # G_A(A) File "/home/jovyan/my-conda-envs/MASKGAN/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/jovyan/my-conda-envs/MASKGAN/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) File "/home/jovyan/NAS/T1toCT_GANS/MaskGAN/MaskGAN-master/MaskGAN-master/models/networks.py", line 472, in forward out = input * attentions[i] RuntimeError: The size of tensor a (241) must match the size of tensor b (244) at non-singleton dimension 3
Do you have any solution?