pycaffe: caffe.Net does not recognize Crop layer

410 views
Skip to first unread message

Wei Liu

unread,
Apr 18, 2016, 4:23:46 PM4/18/16
to Caffe Users
I have a model definition file train.prototxt that I have used to train the model with command line. After training, I use pycaffe to load the model, but caffe.Net could not recognize the Crop layer and then crashed:  

Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Crop (known types:....

Is that Crop layer has not be ported into pycaffe? 

 Here is the python command I used for define the net using prototxt file: 

net = caffe.Net(model_file, model_weights, caffe.TEST)

Thanks for the help. 

Jan

unread,
Apr 19, 2016, 5:28:25 AM4/19/16
to Caffe Users
pycaffe is just a wrapper around libcaffe, there is no such thing as "porting layers to pycaffe". So you are probably using different versions (branches, forks) of caffe somehow or a part of the compiled files are outdated. Usually a clean rebuild of everything solves problems such as this. (This is a good time to do a git pull, too.) And yes, the crop layer should be available.

Jan
Message has been deleted

Wei Liu

unread,
Apr 19, 2016, 10:19:26 AM4/19/16
to Caffe Users
Jan, thanks for the reply. If pycaffe always has all layers defined same as C/C++ interface, why I didn't find 'Crop' layer type in the following 'known types' of the error message: 

F0419 10:14:49.936854 10131 layer_factory.hpp:77] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown layer type: Crop (known types: AbsVal, Accuracy, ArgMax, BNLL, Concat, ContrastiveLoss, Convolution, Data, Deconvolution, Dropout, DummyData, Eltwise, EuclideanLoss, Exp, Flatten, HDF5Data, HDF5Output, HingeLoss, Im2col, ImageData, InfogainLoss, InnerProduct, LRN, MVN, MemoryData, MultinomialLogisticLoss, Pooling, Power, ReLU, Sigmoid, SigmoidCrossEntropyLoss, Silence, Slice, Softmax, SoftmaxWithLoss, Split, TanH, Threshold, WindowData)

And, yes, I"m using the latest master branch of official Caffe repository with a 'git pull' already. 

Again, thanks for the insight. 

Clément Fuji Tsang

unread,
Apr 19, 2016, 11:26:56 AM4/19/16
to Caffe Users
Do you have multiple caffe branchs ? If not Check your PYTHONPATH if it point on the good one.

Wei Liu

unread,
Apr 19, 2016, 11:38:45 AM4/19/16
to Caffe Users
Thanks for the reminding. I use official caffe master branch.

If I use longjon's 'future' branch (https://github.com/longjon/caffe.git) I don't get this error.  So this may be due to the recent 'N-D crop' layer not ported well for pycaffe. 

Clément Fuji Tsang

unread,
Apr 19, 2016, 11:49:48 AM4/19/16
to Caffe Users
Weird, I checked the code, there is no reason for not seeing it in the pycaffe layer's list, I've made few layers, and you just need to implement the "type()" method and instantiate it, which is done on the Crop layer,

Have you done the "make clean" then rebuild it with "make pycaffe" ?

and maybe you should check the "build" directory after make clean.


Le lundi 18 avril 2016 22:23:46 UTC+2, Wei Liu a écrit :

Wei Liu

unread,
Apr 19, 2016, 12:47:50 PM4/19/16
to Caffe Users
See https://github.com/BVLC/caffe/issues/2788, and at the end "@gxdai I ran my python notebook from the caffe-future directory and got rid of the error."

That's 29 days ago, so I suppose nothing has been done since then. 

Evan Shelhamer

unread,
Apr 19, 2016, 5:25:18 PM4/19/16
to Wei Liu, Caffe Users
You are having an installation issue, whether with your library path, python path, or build. pycaffe == caffe with respect to the layers. Try following the advice by Clément to re-build and check your environment.

Crop layer is in master, and all of the models at fcn.berkeleyvision.org were made with pycaffe in master.

Evan Shelhamer





--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/9ecaf8f8-fab9-487b-871c-4f4b1911447e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages