lmb-freiburg / flownet2

FlowNet 2.0: Evolution of Optical Flow Estimation with Deep Networks
https://lmb.informatik.uni-freiburg.de/Publications/2017/IMKDB17/
Other
1.01k stars 318 forks source link

Cannot import custom layers in jupyter notebook #185

Closed adhara123007 closed 5 years ago

adhara123007 commented 5 years ago

Thanks for being active here in resolving queries. This is more of a question since I am a little inexperienced with CAFFE.

I wanted to understand the functions of your custom layers like : resample_layer and data_augmentation layer (not present in the documentation).

So, I created a protxt file with these layers

name: "CaffeNet" layer { name: "data" type: "Input" top: "data" input_param { shape: { dim: 1 dim: 1 dim: 227 dim: 227 } } } layer { name: "Eltwise1" type: "Eltwise" bottom: "data" top: "data_sum" eltwise_param { operation: SUM coeff: 0.00392156862745098 } } layer { name: "Resample1" type: "Resample" bottom: "data_sum" top: "data_resample" resample_param { width: 1024 height: 1792 type: LINEAR antialias: true } }

When I try to use this network in jupyter notebook it fails. However, the layers defined in the documentation (Eltwise and Convolution) work well with the jupyter notebook.

import caffe

model_def = caffe_root + 'examples/augment.prototxt' net = caffe.Net (model_def, caffe.TEST) net.blobs['data'].data[...] = im_input output = net.forward()

As soon as I run this the kernel becomes dead. What I am missing here ?

nikolausmayer commented 5 years ago

Your example works in my Python terminal (I don't have a Jupyter setup), but I had to enable GPU mode (EDIT: because our puny layer implementations do not have CPU code..):

caffe.set_device(1)
caffe.set_mode_gpu()

Is it possible that you have multiple Caffe installations, and that the wrong Python module / .so file is loaded?

adhara123007 commented 5 years ago

It works with my Python terminal . I will check again and close this issue.

adhara123007 commented 5 years ago

Works