Comments (10)
Actually, we want to warp image2 to image1 given the optical flow. The warping here is also called inverse warping. Here is why this is better (slides 1-6): https://www.cs.unc.edu/~lazebnik/research/fall08/lec08_faces.pdf
from spynet.
@anuragranj Very thanks for your replying. It helps me to understand warping and inverse warping better.
from spynet.
The files in extra implement two layers:
- warping: this can be implemented using pytorch/torch.nn.functional.grid_sample. Note that spynet's warping takes optical flow (u,v) as input, and grid_sample takes (2((x+u)/w -0.5), 2((y+v)/h -0.5)) as input, where (w,h) are the image width and height, and (x,y) are the image coordinates. So you would need to scale the flows accordingly while using grid_sample.
- Scale: This can be implemented as bilinear upsampling using pytorch/torch.nn.function.upsample(mode='bilinear')
from spynet.
This is equivalent flow warper in pytorch.
class FlowWarper(nn.Module):
def __init__(self):
super(FlowWarper, self).__init__(w,h)
x = np.arange(0,w)
y = np.arange(0,h)
gx, gy = np.meshgrid(x,y)
self.w = w
self.h = h
self.grid_x = Variable(torch.Tensor(gx), requires_grad=False)
self.grid_y = Variable(torch.Tensor(gy), requires_grad=False)
def forward(self, img, uv):
u = uv[:,0,:,:]
v = uv[:,1,:,:]
X = self.grid_x.unsqueeze(0).expand_as(u) + u
Y = self.grid_y.unsqueeze(0).expand_as(v) + v
X = 2*(X/self.w - 0.5)
Y = 2*(Y/self.h - 0.5)
grid_tf = torch.stack((X,Y), dim=3)
img_tf = F.grid_sample(img, grid_tf)
return img_tf
from spynet.
You may also have a look at: https://github.com/sniklaus/pytorch-spynet
Thank you Anurag for you great work!
from spynet.
@sniklaus Great! I am wondering could you share your reproduced performance?
from spynet.
All necessary code is in the linked repository, what do you need in particular?
from spynet.
Thanks @sniklaus for the pytorch version.
from spynet.
@sniklaus Thanks. Nothing particular is needed.
from spynet.
hi @anuragranj , It seems that if you want to warp an image from image1 to image2 and the optical flow is generated from image1 to image2, you should set "u = -uv[:,0,:,:] and v = -uv[:,1,:,:]" instead of "u = uv[:,0,:,:] v = uv[:,1,:,:]". Is that correct?
from spynet.
Related Issues (19)
- extras/stnbhwd is empty? HOT 1
- reconstruct second image with flow HOT 3
- Training on a different dataset HOT 3
- Training time written on your paper. HOT 1
- performance of flownetS with ft* on kitti HOT 3
- does image format has to be “ppm” HOT 2
- The max flow that the model can predict HOT 1
- Can I use another dataset on this model for example, KTH action dataset HOT 1
- Some questions about the flo result.
- Error:bad argument #1 to 'copy' (sizes do not match HOT 1
- Reimplementation in Tensorflow HOT 1
- Random rotation in training HOT 1
- Training on a custom dataset
- images not normalized HOT 1
- some question about BilinearSamplerBHWD.cu HOT 1
- Compilation on a gcc 6 toolchain? HOT 6
- module 'spynet' not found : No LuaRocks module found for spynet HOT 2
- error in spynet.easycomputeflow HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spynet.