Giter VIP home page Giter VIP logo

liteflownet2-tf2's Introduction

LiteFlowNet2-TF2

This is my TensorFlow 2 implementation of LiteFlowNet2 [1] (an improved version of the original LiteFlowNet [2]).

I used this implementation of the original LiteFlowNet [3] as my starting point: https://github.com/keeper121/liteflownet-tf2
That implementation was inspired by this LiteFlowNet [4] PyTorch implemetation: https://github.com/sniklaus/pytorch-liteflownet
The original Caffe implementation of LiteFlowNet2 is here: https://github.com/twhui/LiteFlowNet2

Please cite the paper accordingly and make sure to adhere to the licensing terms of the authors. Should you be making use of this particular implementation, please acknowledge it appropriately [5].

Paper

Setup

The correlation layer is using the tensorflow_addons package which requires TF 2. I tested with these combinations of packages installed via pip:

pip install --user tensorflow==2.1.0
pip install --user tensorflow_addons==0.7.0

and

pip install --user tensorflow==2.2.0
pip install --user tensorflow_addons==0.10.0

The included weights were converted from the original Caffe implementation [1]. Note that the Sintel and Kitti fine-tuned models have slightly different model architectures.

How to run

To run it on a pair of images, execute the following command to run the Sintel model:

python eval.py --img1=./images/first.png --img2=./images/second.png --use_Sintel=True --display_flow=True --img_out=out.png

And this command for the Kitti model:

python eval.py --img1=./images/first.png --img2=./images/second.png --use_Sintel=False --display_flow=True --img_out=out.png

As you can see below, the results are very close to, but differ a little from the original Caffe implementation. The author of the original LiteFlowNet TF implementation believes it is due to a slightly different feature warping implementation than in the original work.

Comparison

License

Original materials are provided for research purposes only, and commercial use requires consent of the original author. Please see https://github.com/twhui/LiteFlowNet2#license-and-citation for more information.

References

[1]  @inproceedings{hui20liteflownet2,
         author = {Tak-Wai Hui and Xiaoou Tang and Chen Change Loy},
         title = {A {L}ightweight {O}ptical {F}low {CNN} - {R}evisiting {D}ata {F}idelity and {R}egularization},
         booktitle = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
         year = {2020},
         url = {http://mmlab.ie.cuhk.edu.hk/projects/LiteFlowNet/} 
     }
[2]  @inproceedings{Hui_CVPR_2018,
         author = {Tak-Wai Hui and Xiaoou Tang and Chen Change Loy},
         title = {{LiteFlowNet}: A Lightweight Convolutional Neural Network for Optical Flow Estimation},
         booktitle = {IEEE Conference on Computer Vision and Pattern Recognition},
         year = {2018},
         url = {http://mmlab.ie.cuhk.edu.hk/projects/LiteFlowNet/} 
     }
[3]  @misc{liteflownet-tf2,
         author = {Vladimir Mikhelev},
         title = {{LiteFlowNet} inference realization with {Tensorflow 2}},
         year = {2020},
         url = {https://github.com/keeper121/liteflownet-tf2}
    }
[4]  @misc{pytorch-liteflownet,
         author = {Simon Niklaus},
         title = {A Reimplementation of {LiteFlowNet} Using {PyTorch}},
         year = {2019},
         url = {https://github.com/sniklaus/pytorch-liteflownet}
    }
[5]  @misc{LiteFlowNet2-TF2,
         author = {Roger Cheng},
         title = {{LiteFlowNet2} implementation with {TensorFlow 2}},
         year = {2020},
         url = {https://github.com/rogerhcheng/LiteFlowNet2-TF2}
    }

liteflownet2-tf2's People

Contributors

rogerhcheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

liteflownet2-tf2's Issues

flow returns all nans on CPU

Using the same command as in the README:
python eval.py --img1=./images/first.png --img2=./images/second.png --use_Sintel=True --display_flow=True --img_out=out.png

I get a flow result with all nans. Why?

Same for --use_Sintel=False. Basically the same result as this LiteFlowNet issue: keeper121/liteflownet-tf2#7

I am running TensorFlow 2.2.0, addons 0.10.0, Python 3.8.5, Pillow 8.0.1.

Facing below issue while executing the eval script of LiteFlowNet2-TF2

Traceback (most recent call last):
File "eval.py", line 72, in
flow_color = flow_to_color(flow, convert_to_bgr=False)
File "D:\Dataset\LiteFlowNet2-TF2-master\draw_flow.py", line 124, in flow_to_color
return flow_compute_color(u, v, convert_to_bgr)
File "D:\Dataset\LiteFlowNet2-TF2-master\draw_flow.py", line 83, in flow_compute_color
col0 = tmp[k0] / 255.0
IndexError: index -2147483648 is out of bounds for axis 0 with size 55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.