sniklaus / pytorch-pwc

a reimplementation of PWC-Net in PyTorch that matches the official Caffe version
GNU General Public License v3.0
616 stars 123 forks source link

Assertion Error (using images of a different size) #4

Closed Wazaki-Ou closed 6 years ago

Wazaki-Ou commented 6 years ago

It seems like using images with a different size throws this error. I would like to double check that modifying that part of the code to make it accept images with other size will not create an issue in calculating the flow. Also. if there is any specific part of the code I need to be careful with when modifying.

Thank you

sniklaus commented 6 years ago

I have tried in on different sizes as well without any issues. The important part is that the flow is being rescaled, just like in the official implementation.

https://github.com/sniklaus/pytorch-pwc/blob/9cf1e29a376987188bba85837bbb93b4d2e12474/run.py#L328

Wazaki-Ou commented 6 years ago

This is the error I get: image

my picture is a jpg of size 1920*1080

sniklaus commented 6 years ago

I am afraid that I a little bit confused. It says remember that there is no guarantee for correctness, comment this line out if you acknowledge this and want to continue, have you tried commenting the line out?

Wazaki-Ou commented 6 years ago

For anyone who faces the same issue, commenting the lines restricting the size can solve the issue. Thanks !!

sniklaus commented 6 years ago

I wouldn't necessarily call it an issue though, it is more like an acknowledgement.

SystemErrorWang commented 5 years ago

in fact, I used inputs with same size and got size mismatch problem in the middle of the network.

File "/home/wangxinrui/bbox_net/flow_net.py", line 104, in forward tensorInput = torch.cat([ tensorInput, self.tensorPartial ], 1) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 8 and 7 in dimension 2 at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/generic/THCTensorMath.cu:87

sniklaus commented 5 years ago

Would you mind sharing the images that cause this error? If not, what is their resolution?

SystemErrorWang commented 5 years ago

I tested again and found 224224 resolution caused this problem while 256256 worked well. I guess the image resolution should be divided by 64.

sniklaus commented 5 years ago

I am not exactly sure what happened in your case, see the following excerpt.

https://github.com/sniklaus/pytorch-pwc/blob/e76ece261ba5a4b3411ac48971fdc6f689b7df38/run.py#L311

Which ensures that the resolution is divisible by 64 and resizes 224x224 to 256x256 accordingly.