From 0c70c3c7393bd24793796350e3635b6b04fb95ea Mon Sep 17 00:00:00 2001 From: Anurag Ranjan Date: Tue, 8 Nov 2016 00:25:48 +0100 Subject: [PATCH] Updated Readme --- README.md | 66 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 9fbd0e0..c2b8aea 100644 --- a/README.md +++ b/README.md @@ -1,51 +1,57 @@ # SPyNet: Spatial Pyramid Network for Optical Flow - +This code is based on the paper [Optical Flow Estimation using a Spatial Pyramid Network](https://arxiv.org/abs/1611.00850) ## First things first You need to have [Torch.](http://torch.ch/docs/getting-started.html#_) Install other required packages - - cd extras/spybhwd - luarocks make - - cd ../stnbhwd - luarocks make - +```bash +cd extras/spybhwd +luarocks make +cd ../stnbhwd +luarocks make +``` ## For Fast Performace #### Set up SPyNet Set up SPyNet according to the image size and model. For optimal performance, make sure the image width and height are a multiple of 32. You can also specify your favorite fine tuned model. The present supported modes are `sintelFinal`(default) and `sintelClean`. - - spynet = require('spynet') - computeFlow = spynet.setup(512, 384, 'sintelFinal') - +```lua +spynet = require('spynet') +computeFlow = spynet.setup(512, 384, 'sintelFinal') +``` Now you can call computeFlow anytime to estimate optical flow between image pairs. #### Computing flow Load an image pair and stack it. - - require 'image' - im1 = image.load('samples/00001_img1.ppm' ) - im2 = image.load('samples/00001_img2.ppm' ) - im = torch.cat(im1, im2, 1) - +```lua +require 'image' +im1 = image.load('samples/00001_img1.ppm' ) +im2 = image.load('samples/00001_img2.ppm' ) +im = torch.cat(im1, im2, 1) +``` SPyNet works with batches of data on CUDA. So, compute flow using - - im = im:resize(1, im:size(1), im:size(2), im:size(3)):cuda() - flow = computeFlow(im) - +```lua +im = im:resize(1, im:size(1), im:size(2), im:size(3)):cuda() +flow = computeFlow(im) +``` You can also use batch-mode, if your images `im` are a tensor of size `Bx6xHxW`, of batch size B with 6 RGB pair channels. You can directly use: - - flow = computeFlow(im) - +```lua +flow = computeFlow(im) +``` ## For Easy Usage ### Coming Soon. ## Timing Benchmarks Our timing benchmark is set up on Flying chair dataset. To test it, you need to download - - wget http://lmb.informatik.uni-freiburg.de/resources/datasets/FlyingChairs/FlyingChairs.zip - +```bash +wget http://lmb.informatik.uni-freiburg.de/resources/datasets/FlyingChairs/FlyingChairs.zip +``` Run the timing benchmark +```bash +th timing_benchmark.lua -data YOUR_FLYING_CHAIRS_DATA_DIRECTORY +``` + +## References +1. Our warping code is based on [qassemoquab/stnbhwd.](https://github.com/qassemoquab/stnbhwd) +2. Dosovitskiy, Alexey, et al. "Flownet: Learning optical flow with convolutional networks." 2015 IEEE International Conference on Computer Vision (ICCV). IEEE, 2015. - th timing_benchmark.lua -data YOUR_FLYING_CHAIRS_DATA_DIRECTORY - +## When using this code, please cite +Anurag Ranjan and Michael Black, "Optical Flow Estimation using a Spatial Pyramid Network", arXiv preprint arXiv:1611.00850 cs.CV (2016).