sergeywong / cp-vton

Reimplemented code for "Toward Characteristic-Preserving Image-based Virtual Try-On Network"
MIT License
474 stars 182 forks source link

Errors of tensor size while running test.py #5

Closed solitarysandman closed 5 years ago

solitarysandman commented 5 years ago

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 _cpdataset.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 _cpdataset.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?

jakubLangr commented 4 years ago

Hi @solitarysandman how did you resolve this issue?

solitarysandman commented 4 years ago

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

jakubLangr commented 4 years ago

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?

solitarysandman commented 4 years ago

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)

jakubLangr commented 4 years ago

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

solitarysandman commented 4 years ago

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)

jakubLangr commented 4 years ago

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