vt-vl-lab / flownet2.pytorch

Off-the-shelf FlowNet module in PyTorch-0.3.0
Apache License 2.0
118 stars 37 forks source link

Does the size of referenced image must be a multiplier of 64? #2

Closed ZongweiZhou1 closed 6 years ago

ZongweiZhou1 commented 6 years ago

I run the demo with my own images (size: 1080x1920). Then some problems are encounted

Traceback (most recent call last):
File "demo.py", line 30, in <module> pred_flow = flownet2(ims_v).cpu().data
 File "/data/zwzhou/miniconda2/envs/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 325, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/zwzhou/DownloadCode/PYTORCH/pytorch_flownet2/FlowNet2_src/models/flownet2.py", line 76, in forward   flownetc_flow2 = self.flownetc(x)[0]
  File "/data/zwzhou/miniconda2/envs/pytorch/lib/python3.5/site-ckages/torch/nn/modules/module.py", line 325, in __call__
    result = self.forward(*input, **kwargs)
  File "/data/zwzhou/DownloadCode/PYTORCH/pytorch_flownet2/FlowNet2_src/models/components/FlowNetC.py", line 120, in forward  concat3 = torch.cat((out_conv3_1, out_deconv3, flow4_up), 1)
RuntimeError: inconsistent tensor sizes at /opt/conda/conda-bld/pytorch_1512382878663/work/torch/lib/THC/generic/THCTensorMath.cu:157

when I try other image pairs (576x768), it can run without issues.

What should I do to process this images (1080x1920), just pad the images to be a multiplier of 64 with zero?

Yuliang-Zou commented 6 years ago

Hi @ZongweiZhou1 , yes currently the input size must be a multiplier of 64. You can resize it to get the output, and then resize it back to the original size. But notice that you also need to scale up the values of the flow.

You can try the tensorflow version, that one should be fine with any sizes (as long as it is large enough)

ZongweiZhou1 commented 6 years ago

@Yuliang-Zou I solved the problem via padding image to be a multiplier of 64. Then I run demo with FlowNet2_checkpoint and get the flow image as provided in readme.md. However, some meanless grid images are obtained when the pretrained weight is changed to FlowNet2-CS or FlowNet-C. What should i do if i want to use the small pretrained weights? Do you have some advice?

Yuliang-Zou commented 6 years ago

@ZongweiZhou1 Padding would cause some weird effects along the boundary, I suggest that you use resize instead. It should at least give you some reasonable result, even if you use smaller network. But I haven't really tried FlowNet2-CS or C.

ZongweiZhou1 commented 6 years ago

OK~ Thanks a lot