yz-wang / Cycle-SNSPGAN

MIT License
12 stars 2 forks source link

testing error #1

Open MariamAlz opened 2 years ago

MariamAlz commented 2 years ago

While trying to test using:

python test.py --dataroot datasets/underwater_dataset/ --cuda

I get this error:

Namespace(batchSize=1, cuda=True, dataroot='datasets/underwater_dataset/', generator_A2B='output/netG_A2B.pth', generator_B2A='output/netG_B2A.pth', input_nc=3, n_cpu=0, output_nc=3, sizeh=308, sizew=548)
Traceback (most recent call last):
  File "test.py", line 55, in <module>
    real_A = Variable(input_A.copy_(batch['A']))
RuntimeError: The size of tensor a (548) must match the size of tensor b (480) at non-singleton dimension 3
yz-wang commented 2 years ago

The reason for the error is that the size of the test image is not the same as the one given in test.py (line 21 & 22). As the code framework is based on the original CycleGAN, their code has fixed the sizes of the test image (e.g., 548, 308), so you need to match the width and height of test.py (line 21 & 22) to the sizes of your test image (548->480).

If the image you are testing contains different dimensions, it is recommended to modify the code to read in the image dimensions directly rather than fixing them.