sniklaus / pytorch-pwc

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

how to compute optical flow for small size imgs? #49

Closed Pixie8888 closed 3 years ago

Pixie8888 commented 3 years ago

Hi, Thanks for providing easy way of running pwcnet! I want to use pwc-net in my own dataset, inside which, all images are in 48*48 gray scale. Can you give some tips on how to preprocess these images? Do I need to resize them to (436, 1024) first? Do I need to convert them to rgb imgs? Thanks! image

sniklaus commented 3 years ago

The pyramid feature extractor downsamples the input six times as follows.

https://github.com/sniklaus/pytorch-pwc/blob/b638427cc9aad4bc20d01d50a16095a29cef3c75/run.py#L78-L130

The input thus has to be at least 128x128 such that the last layer is 2x2 (it cannot be 1x1 in practice as it would try to compute flow where there is none). Such a small input probably deviates quite a bit from what the network was trained on though, so I would recommend not going below 256x256 instead.