GithubHelp home page GithubHelp logo

pytorch-liteflownet3's Introduction

pytorch-liteflownet3

This is a personal reimplementation of LiteFlowNet3 [1] using PyTorch, which is inspired by the pytorch-liteflownet implementation of LiteFlowNet by sniklaus. Should you be making use of this work, please cite the paper accordingly. Also, make sure to adhere to the licensing terms of the authors.

For the original Caffe version of this work, please see: https://github.com/twhui/LiteFlowNet3

setup

The correlation layer is borrowed from NVIDIA-flownet2-pytorch

cd correlation_package
python setup.py install

usage

Download network-sintel.pytorch from Google-Drive . To run it on your demo pair of images, use the following command. Only sintel-model is supported now. It's tested with pytorch 1.3.0 and cuda-9.0, later pytorch/cuda version should also work.

python run.py

I am afraid that I cannot guarantee that this reimplementation is correct. However, it produced results pretty much identical to the implementation of the original authors in the examples that I tried. There are some numerical deviations that stem from differences in the DownsampleLayer of Caffe and the torch.nn.functional.interpolate function of PyTorch. Please feel free to contribute to this repository by submitting issues and pull requests.

comparison

Comparison

license

As stated in the licensing terms of the authors of the paper, their material is provided for research purposes only. Please make sure to further consult their licensing terms.

references

[1]  @inproceedings{hui2020liteflownet3,
  title={LiteFlowNet3: Resolving Correspondence Ambiguity for More Accurate Optical Flow Estimation},
  author={Hui, Tak-Wai and Loy, Chen Change},
  booktitle={European Conference on Computer Vision},
  pages={169--184},
  year={2020},
  organization={Springer}
}

Acknowledgments

Many code of this repo are borrowed from pytorch-liteflownet. And the correlation layer is borrowed from NVIDIA-Flownet2-pytorch.

pytorch-liteflownet3's People

Contributors

lhao0301 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

pytorch-liteflownet3's Issues

How to warp the image with optical flow (.flo)?

Thank you for your reimplementation of LiteFlowNet3 using PyTorch, it is very useful to me. However, I don’t know how to warp the image using the output optical flow file (.flo).
I use the next flow_warp function, but it does not work.

def flow_warp(x, flow, padding_mode='zeros'):
    """Warp an image or feature map with optical flow
    Args:
        x (Tensor): size (n, c, h, w)
        flow (Tensor): size (n, 2, h, w), values range from -1 to 1 (relevant to image width or height)
        padding_mode (str): 'zeros' or 'border'

    Returns:
        Tensor: warped image or feature map
    """
    assert x.size()[-2:] == flow.size()[-2:]
    n, _, h, w = x.size()
    x_ = torch.arange(w).view(1, -1).expand(h, -1)
    y_ = torch.arange(h).view(-1, 1).expand(-1, w)
    grid = torch.stack([x_, y_], dim=0).float().cuda()
    grid = grid.unsqueeze(0).expand(n, -1, -1, -1)
    grid[:, 0, :, :] = 2 * grid[:, 0, :, :] / (w - 1) - 1
    grid[:, 1, :, :] = 2 * grid[:, 1, :, :] / (h - 1) - 1
    grid += flow
    grid = grid.permute(0, 2, 3, 1)
    return torch.nn.functional.grid_sample(x, grid)

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.