Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit build.py, and install successfully. #70

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ We've included caffe pre-trained models. Should you use these pre-trained weight
[![Predicted flows on MPI-Sintel](./image.png)](https://www.youtube.com/watch?v=HtBmabY8aeU "Predicted flows on MPI-Sintel")

## Reference
If you find this implementation useful in your work, please acknowledge it appropriately and cite the paper using:
If you find this implementation useful in your work, please acknowledge it appropriately and cite the paper:
````
@InProceedings{IMKDB17,
author = "E. Ilg and N. Mayer and T. Saikia and M. Keuper and A. Dosovitskiy and T. Brox",
Expand All @@ -97,6 +97,19 @@ If you find this implementation useful in your work, please acknowledge it appro
url = "http://lmb.informatik.uni-freiburg.de//Publications/2017/IMKDB17"
}
````
```
@misc{flownet2-pytorch,
author = {Fitsum Reda and Robert Pottorff and Jon Barker and Bryan Catanzaro},
title = {flownet2-pytorch: Pytorch implementation of FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks},
year = {2017},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/NVIDIA/flownet2-pytorch}}
}
```
## Related Optical Flow Work from Nvidia
Code (in Caffe and Pytorch): [PWC-Net](https://github.com/NVlabs/PWC-Net) <br />
Paper : [PWC-Net: CNNs for Optical Flow Using Pyramid, Warping, and Cost Volume](https://arxiv.org/abs/1709.02371).

## Acknowledgments
Parts of this code were derived, as noted in the code, from [ClementPinard/FlowNetPytorch](https://github.com/ClementPinard/FlowNetPytorch).
14 changes: 9 additions & 5 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,27 @@ def init_deconv_bilinear(self, weight):
return

def forward(self, inputs):
# input format: 5d tensor, (batch, rgb, img #, x, y)
# normalizing imgs
rgb_mean = inputs.contiguous().view(inputs.size()[:2]+(-1,)).mean(dim=-1).view(inputs.size()[:2] + (1,1,1,))

x = (inputs - rgb_mean) / self.rgb_max

# squish the img # dimension by concatenating the rgb channels
x1 = x[:,:,0,:,:]
x2 = x[:,:,1,:,:]
x = torch.cat((x1,x2), dim = 1)

# flownetc
flownetc_flow2 = self.flownetc(x)[0]
flownetc_flow2 = self.flownetc(x)[0] # only return flow2, since the network returns flow6 to flow2
flownetc_flow = self.upsample1(flownetc_flow2*self.div_flow)

# warp img1 to img0; magnitude of diff between img0 and and warped_img1,
# warp img1 to img0; magnitude of diff between img0 and and warped_img1, i.e. brightness error
# combine the flow with img1 to 'reconstruct' img0
resampled_img1 = self.resample1(x[:,3:,:,:], flownetc_flow)
diff_img0 = x[:,:3,:,:] - resampled_img1
diff_img0 = x[:,:3,:,:] - resampled_img1 # brightness error
norm_diff_img0 = self.channelnorm(diff_img0)

# concat img0, img1, img1->img0, flow, diff-mag ;
# concat img0, img1, warped img1, flow, normalized brightness error
concat1 = torch.cat((x, resampled_img1, flownetc_flow/self.div_flow, norm_diff_img0), dim=1)

# flownets1
Expand Down
5 changes: 3 additions & 2 deletions networks/channelnorm_package/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
package=False,
relative_to=this_folder,
define_macros=Defines,
extra_objects=[os.path.join(this_folder, Object) for Object in Objects]
extra_objects=[os.path.join(this_folder, Object) for Object in Objects],
extra_compile_args=['-std=c99']
)

if __name__ == '__main__':
ffi.build()
ffi.build()
3 changes: 2 additions & 1 deletion networks/channelnorm_package/functions/channelnorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def forward(ctx, input1, norm_deg=2):

channelnorm.ChannelNorm_cuda_forward(input1, output, norm_deg)
ctx.save_for_backward(input1, output)

ctx.norm_deg = norm_deg

return output

@staticmethod
Expand Down
3 changes: 2 additions & 1 deletion networks/correlation_package/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
package=False,
relative_to=this_folder,
define_macros=Defines,
extra_objects=[os.path.join(this_folder, Object) for Object in Objects]
extra_objects=[os.path.join(this_folder, Object) for Object in Objects],
extra_compile_args=['-std=c99']
)

if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions networks/resample2d_package/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
package=False,
relative_to=this_folder,
define_macros=Defines,
extra_objects=[os.path.join(this_folder, Object) for Object in Objects]
extra_objects=[os.path.join(this_folder, Object) for Object in Objects],
extra_compile_args=['-std=c99']
)

if __name__ == '__main__':
ffi.build()
ffi.build()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
setproctitle==1.1.10
tensorboardX==1.2
colorama==0.3.9