ganilla icon indicating copy to clipboard operation
ganilla copied to clipboard

Change the output channel

Open Wangmmstar opened this issue 2 years ago • 4 comments

Hello. Thank you for the contribution! I have a novice question about the output channel. I changed the output channel in the base_option.py to 1 as I input gray images. But there is one error thrown out: RuntimeError: The size of tensor a (32) must match the size of tensor b (31) at non-singleton dimension 3 I can't figure out why this would happen. Could you please tell me what could be the reason and where should I change in the network.py file?

Thank you very much!

Wangmmstar avatar Jul 10 '22 04:07 Wangmmstar

Hello, looks like the problem is with the image width, not the channel. are you using the resize operations, specifically "--resize_or_crop" flag with any other option than "None". Else you need to resize your images to 256x256. If you are doing so and still there is a problem, could you share me a sample failing image file so I can debug and try to figure out the problem.

Best

giddyyupp avatar Sep 28 '22 14:09 giddyyupp

Hi @giddyyupp ,

I am getting the same error. These are the parameters I am using: python test.py --dataroot ../my_own_data --name PP --model test --gpu_ids 0 --loadSize 512 --fineSize 512 --resize_or_crop 'scale_width' --verbose

It happens just when I put the flag --resize_or_crop 'scale_width'.

And this is the error I get: RuntimeError: The size of tensor a (44) must match the size of tensor b (43) at non-singleton dimension 2

Thanks

hdnh2006 avatar Mar 30 '23 11:03 hdnh2006

Hello @giddyyupp,

I have a quick question regarding the input image size requirement. Could you kindly provide some information about the preferred dimensions or aspect ratio that the images should have?

I have tried using an image with dimensions of 4000x2250, which was accepted without any issues. However, I encountered difficulties when using images with dimensions such as 4496x2776. It would be helpful to know the specific aspect ratio or guidelines for the image dimensions.

Thank you in advance for your assistance.

hdnh2006 avatar Jun 12 '23 14:06 hdnh2006

Hello, Yes the problem is with the dimensions of the image indeed, since i faced the same problem. In the original CyleGan repo, they updated the implementation of 'scale_width' transform which makes sure that the height of the image becomes at least the crop size: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix/blob/9f8f61e5a375c2e01c5187d093ce9c2409f409b0/data/base_dataset.py#L135

I guess I need to update the transform part or the whole base_dataset.py :(

giddyyupp avatar Oct 25 '23 18:10 giddyyupp