sergeywong/cp-vton

Errors of tensor size while running test.py

solitarysandman opened this issue · 7 comments

RuntimeError: The size of tensor a (270) must match the size of tensor b (3) at non-singleton dimension 2

Hi,

I am getting a tensor dimension error while running test.py as below:
python test.py --name gmm_traintest_new --stage GMM --workers 4 --datamode test --data_list test_pairs.txt --checkpoint checkpoints/gmm_train_new/gmm_final.pth

The error seems to arise from cp_dataset.py module in line 91. Somehow the size/shape of the image read is (3, 360, 270) where the image is of 360x270 pix. This throws the following error:
image

I've fixed this issue by using permute on the object im in cp_dataset.py after the image has been read and transformed. Although it fixes the error shown in the screengrab above, I still have some issues with the implementation. Seems like the input size of image MUST be 256x192?

Hi @solitarysandman how did you resolve this issue?

Well, the tensors were of the shape C, H, W instead of H, W, C. I just switched axis to fix this.

Hi @solitarysandman thank you so much for a quick response. But it seems to happen to me under both orders C,H,W and H,W,C. Any ideas?
Screen Shot 2019-09-18 at 12 56 29 PM

Is there something I can do in pre-processing?

Can you print the shape of both im and pcm? They probably have a shape mismatch, which you'll need to address in a data preprocessing step (within cp_dataset)

So unless I'm crazy they're both the same?

The ones without description are _im_s

Screen Shot 2019-09-18 at 1 18 53 PM

This is a different error. Looks like when you're concatenating shape, im_h, pose_map, they can't be stacked because of shape mismatch?

Can you try something like this before you define agnostic?

print(shape.shape, im_h.shape, pose_map.shape)

Hi @solitarysandman — sorry just got back from lunch. Ignore the previous message.

Screen Shot 2019-09-18 at 2 50 46 PM

I think it is fixable, but the first error is if I remove the reshape command to be [3, 256, 192], the second is when I include it. I can reshape the other three but it seems to me that it was intended to be without the reshape from the start.

EDIT:
I was able to get a yet a different error by calling:
im_h = im_h.permute(2,0,1) right before the cat