sniklaus / pytorch-liteflownet

a reimplementation of LiteFlowNet in PyTorch that matches the official Caffe version

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom images of different sizes

BonJovi1 opened this issue · comments

Hi @sniklaus
Thank you so much for your code!
Sorry for the really sill question. I was able to set up your code and got it working for the sample images (1024x436) you've provided. I wish to estimate the flow for images that are (512 x 384). I commented the following lines from your code:

assert(intWidth == 1024)
assert(intHeight == 436)

And ran it, but I'm getting the following error:

Traceback (most recent call last):
  File "run.py", line 379, in <module>
    tenOutput = estimate(tenFirst, tenSecond)
  File "run.py", line 356, in estimate
    tenPreprocessedFirst = tenFirst.cuda().view(1, 3, intHeight, intWidth)

RuntimeError: shape '[1, 3, 384, 512]' is invalid for input of size 786432

Could you kindly advise me on how to fix this? Do we have to modify the architecture of the network, if we are only testing it out?
Thank you,
Abhinav

Also, I tried resizing my images to 1024x436, but it still throws a similar error

Traceback (most recent call last):
  File "run.py", line 379, in <module>
    tenOutput = estimate(tenFirst, tenSecond)
  File "run.py", line 356, in estimate
    tenPreprocessedFirst = tenFirst.cuda().view(1, 3, intHeight, intWidth)
RuntimeError: shape '[1, 3, 436, 1024]' is invalid for input of size 1785856

I double checked, my image files are not corrupt. Any idea why this may be happening?
Thanks!
Abhinav

1024 * 436 * 4 == 1785856

Looks like your images are RGBA and have four channels. You can either change the code to only take the first three channels or convert your RGBA images to RGB instead.