Can't compile, even with caffe installed.
Hey, I've been trying to compile a program to classify images using PyCaffe. I'm getting the code from this example: http://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb .
All the functions starting with % or ! are getting Syntax Error, even if they're supposed to work on iPython(as I saw some people say on internet). Based on the internet(http://stackoverflow.com/questions/35595766/matplotlib-line-magic-causes-syntaxerror-in-python-script), I changed my syntax. However, running "python code.py" gives me the error:
Traceback (most recent call last):
File "../python/projeto1.py", line 7, in
But I kept tryin' changing some little things on the original code: On all lines that used "%" in the beginning, I changed the syntax to get_ipython().magic('function()'). For example, on line 87 of the code, I changed "%timeit net.forward()" to "get_ipython().magic('timeit net.forward()') ing some little things on the original code: On all lines that used "%" in the beginning, I changed the syntax to get_ipython().magic('function()'). For example, on line 87 of the code, I changed "%timeit net.forward()" to "get_ipython().magic('timeit net.forward()')". After doing that, I(guess) I solved all the "!" issues too, basically just commenting them, because all they do is get or download something. I'm not needing that, because I already downloaded manually. Finally, I tried compiling it again, but this time using iPython. So I ran "ipython code.py", and it begins to work, BUT it's aborted. The error is the following:
CaffeNet found. WARNING: Logging before InitGoogleLogging() is written to STDERR W0819 13:01:07.594172 5427 _caffe.cpp:122] DEPRECATION WARNING - deprecated use of Python interface W0819 13:01:07.594208 5427 _caffe.cpp:123] Use this instead (with the named "weights" parameter): W0819 13:01:07.594223 5427 _caffe.cpp:125] Net('../models/bvlc_reference_caffenet/deploy.prototxt', 1, weights='../models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel') I0819 13:01:07.595712 5427 net.cpp:58] Initializing net from parameters: name: "CaffeNet" state { phase: TEST level: 0 } layer { name: "data" type: "Input" top: "data" input_param { shape { dim: 10 dim: 3 dim: 227 dim: 227 } } } layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" convolution_param { num_output: 96 kernel_size: 11 stride: 4 } } layer { name: "relu1" type: "ReLU" bottom: "conv1" top: "conv1" } layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "norm1" type: "LRN" bottom: "pool1" top: "norm1" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 } } layer { name: "conv2" type: "Convolution" bottom: "norm1" top: "conv2" convolution_param { num_output: 256 pad: 2 kernel_size: 5 group: 2 } } layer { name: "relu2" type: "ReLU" bottom: "conv2" top: "conv2" } layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "norm2" type: "LRN" bottom: "pool2" top: "norm2" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 } } layer { name: "conv3" type: "Convolution" bottom: "norm2" top: "conv3" convolution_param { num_output: 384 pad: 1 kernel_size: 3 } } layer { name: "relu3" type: "ReLU" bottom: "conv3" top: "conv3" } layer { name: "conv4" type: "Convolution" bottom: "conv3" top: "conv4" convolution_param { num_output: 384 pad: 1 kernel_size: 3 group: 2 } } layer { name: "relu4" type: "ReLU" bottom: "conv4" top: "conv4" } layer { name: "conv5" type: "Convolution" bottom: "conv4" top: "conv5" convolution_param { num_output: 256 pad: 1 kernel_size: 3 group: 2 } } layer { name: "relu5" type: "ReLU" bottom: "conv5" top: "conv5" } layer { name: "pool5" type: "Pooling" bottom: "conv5" top: "pool5" pooling_param { pool: MAX kernel_size: 3 stride: 2 } } layer { name: "fc6" type: "InnerProduct" bottom: "pool5" top: "fc6" inner_product_param { num_output: 4096 } } layer { name: "relu6" type: "ReLU" bottom: "fc6" top: "fc6" } layer { name: "drop6" type: "Dropout" bottom: "fc6" top: "fc6" dropout_param { dropout_ratio: 0.5 } } layer { name: "fc7" type: "InnerProduct" bottom: "fc6" top: "fc7" inner_product_param { num_output: 4096 } } layer { name: "relu7" type: "ReLU" bottom: "fc7" top: "fc7" } layer { name: "drop7" type: "Dropout" bottom: "fc7" top: "fc7" dropout_param { dropout_ratio: 0.5 } } layer { name: "fc8" type: "InnerProduct" bottom: "fc7" top: "fc8" inner_product_param { num_output: 1000 } } layer { name: "prob" type: "Softmax" bottom: "fc8" top: "prob" } I0819 13:01:07.595903 5427 layer_factory.hpp:77] Creating layer data I0819 13:01:07.595917 5427 net.cpp:100] Creating Layer data I0819 13:01:07.595937 5427 net.cpp:408] data -> data I0819 13:01:07.595973 5427 net.cpp:150] Setting up data I0819 13:01:07.595986 5427 net.cpp:157] Top shape: 10 3 227 227 (1545870) I0819 13:01:07.595990 5427 net.cpp:165] Memory required for data: 6183480 I0819 13:01:07.596004 5427 layer_factory.hpp:77] Creating layer conv1 I0819 13:01:07.596014 5427 net.cpp:100] Creating Layer conv1 I0819 13:01:07.596022 5427 net.cpp:434] conv1 <- data I0819 13:01:07.596055 5427 net.cpp:408] conv1 -> conv1 I0819 13:01:07.596148 5427 net.cpp:150] Setting up conv1 I0819 13:01:07.596160 5427 net.cpp:157] Top shape: 10 96 55 55 (2904000) I0819 13:01:07.596168 5427 net.cpp:165] Memory required for data: 17799480 I0819 13:01:07.596189 5427 layer_factory.hpp:77] Creating layer relu1 I0819 13:01:07.596204 5427 net.cpp:100] Creating Layer relu1 I0819 13:01:07.596213 5427 net.cpp:434] relu1 <- conv1 I0819 13:01:07.596225 5427 net.cpp:395] relu1 -> conv1 (in-place) I0819 13:01:07.596238 5427 net.cpp:150] Setting up relu1 I0819 13:01:07.596249 5427 net.cpp:157] Top shape: 10 96 55 55 (2904000) I0819 13:01:07.596258 5427 net.cpp:165] Memory required for data: 29415480 I0819 13:01:07.596267 5427 layer_factory.hpp:77] Creating layer pool1 I0819 13:01:07.596278 5427 net.cpp:100] Creating Layer pool1 I0819 13:01:07.596290 5427 net.cpp:434] pool1 <- conv1 I0819 13:01:07.596302 5427 net.cpp:408] pool1 -> pool1 I0819 13:01:07.596321 5427 net.cpp:150] Setting up pool1 I0819 13:01:07.596335 5427 net.cpp:157] Top shape: 10 96 27 27 (699840) I0819 13:01:07.596343 5427 net.cpp:165] Memory required for data: 32214840 I0819 13:01:07.596352 5427 layer_factory.hpp:77] Creating layer norm1 I0819 13:01:07.596365 5427 net.cpp:100] Creating Layer norm1 I0819 13:01:07.596374 5427 net.cpp:434] norm1 <- pool1 I0819 13:01:07.596386 5427 net.cpp:408] norm1 -> norm1 I0819 13:01:07.596403 5427 net.cpp:150] Setting up norm1 I0819 13:01:07.596415 5427 net.cpp:157] Top shape: 10 96 27 27 (699840) I0819 13:01:07.596423 5427 net.cpp:165] Memory required for data: 35014200 I0819 13:01:07.596431 5427 layer_factory.hpp:77] Creating layer conv2 I0819 13:01:07.596446 5427 net.cpp:100] Creating Layer conv2 I0819 13:01:07.596457 5427 net.cpp:434] conv2 <- norm1 I0819 13:01:07.596468 5427 net.cpp:408] conv2 -> conv2 I0819 13:01:07.596886 5427 net.cpp:150] Setting up conv2 I0819 13:01:07.596902 5427 net.cpp:157] Top shape: 10 256 27 27 (1866240) I0819 13:01:07.596910 5427 net.cpp:165] Memory required for data: 42479160 I0819 13:01:07.596928 5427 layer_factory.hpp:77] Creating layer relu2 I0819 13:01:07.596941 5427 net.cpp:100] Creating Layer relu2 I0819 13:01:07.596949 5427 net.cpp:434] relu2 <- conv2 I0819 13:01:07.596966 5427 net.cpp:395] relu2 -> conv2 (in-place) I0819 13:01:07.596978 5427 net.cpp:150] Setting up relu2 I0819 13:01:07.596989 5427 net.cpp:157] Top shape: 10 256 27 27 (1866240) I0819 13:01:07.596997 5427 net.cpp:165] Memory required for data: 49944120 I0819 13:01:07.597005 5427 layer_factory.hpp:77] Creating layer pool2 I0819 13:01:07.597018 5427 net.cpp:100] Creating Layer pool2 I0819 13:01:07.597025 5427 net.cpp:434] pool2 <- conv2 I0819 13:01:07.597038 5427 net.cpp:408] pool2 -> pool2 I0819 13:01:07.597054 5427 net.cpp:150] Setting up pool2 I0819 13:01:07.597066 5427 net.cpp:157] Top shape: 10 256 13 13 (432640) I0819 13:01:07.597074 5427 net.cpp:165] Memory required for data: 51674680 I0819 13:01:07.597082 5427 layer_factory.hpp:77] Creating layer norm2 I0819 13:01:07.597096 5427 net.cpp:100] Creating Layer norm2 I0819 13:01:07.597105 5427 net.cpp:434] norm2 <- pool2 I0819 13:01:07.597116 5427 net.cpp:408] norm2 -> norm2 I0819 13:01:07.597132 5427 net.cpp:150] Setting up norm2 I0819 13:01:07.597144 5427 net.cpp:157] Top shape: 10 256 13 13 (432640) I0819 13:01:07.597152 5427 net.cpp:165] Memory required for data: 53405240 I0819 13:01:07.597160 5427 layer_factory.hpp:77] Creating layer conv3 I0819 13:01:07.597175 5427 net.cpp:100] Creating Layer conv3 I0819 13:01:07.597184 5427 net.cpp:434] conv3 <- norm2 I0819 13:01:07.597196 5427 net.cpp:408] conv3 -> conv3 I0819 13:01:07.598115 5427 net.cpp:150] Setting up conv3 I0819 13:01:07.598152 5427 net.cpp:157] Top shape: 10 384 13 13 (648960) I0819 13:01:07.598160 5427 net.cpp:165] Memory required for data: 56001080 I0819 13:01:07.598186 5427 layer_factory.hpp:77] Creating layer relu3 I0819 13:01:07.598202 5427 net.cpp:100] Creating Layer relu3 I0819 13:01:07.598212 5427 net.cpp:434] relu3 <- conv3 I0819 13:01:07.598230 5427 net.cpp:395] relu3 -> conv3 (in-place) I0819 13:01:07.598265 5427 net.cpp:150] Setting up relu3 I0819 13:01:07.598276 5427 net.cpp:157] Top shape: 10 384 13 13 (648960) I0819 13:01:07.598284 5427 net.cpp:165] Memory required for data: 58596920 I0819 13:01:07.598292 5427 layer_factory.hpp:77] Creating layer conv4 I0819 13:01:07.598309 5427 net.cpp:100] Creating Layer conv4 I0819 13:01:07.598317 5427 net.cpp:434] conv4 <- conv3 I0819 13:01:07.598332 5427 net.cpp:408] conv4 -> conv4 I0819 13:01:07.599205 5427 net.cpp:150] Setting up conv4 I0819 13:01:07.599228 5427 net.cpp:157] Top shape: 10 384 13 13 (648960) I0819 13:01:07.599236 5427 net.cpp:165] Memory required for data: 61192760 I0819 13:01:07.599251 5427 layer_factory.hpp:77] Creating layer relu4 I0819 13:01:07.599264 5427 net.cpp:100] Creating Layer relu4 I0819 13:01:07.599273 5427 net.cpp:434] relu4 <- conv4 I0819 13:01:07.599289 5427 net.cpp:395] relu4 -> conv4 (in-place) I0819 13:01:07.599303 5427 net.cpp:150] Setting up relu4 I0819 13:01:07.599314 5427 net.cpp:157] Top shape: 10 384 13 13 (648960) I0819 13:01:07.599323 5427 net.cpp:165] Memory required for data: 63788600 I0819 13:01:07.599331 5427 layer_factory.hpp:77] Creating layer conv5 I0819 13:01:07.599345 5427 net.cpp:100] Creating Layer conv5 I0819 13:01:07.599354 5427 net.cpp:434] conv5 <- conv4 I0819 13:01:07.599370 5427 net.cpp:408] conv5 -> conv5 I0819 13:01:07.599946 5427 net.cpp:150] Setting up conv5 I0819 13:01:07.599961 5427 net.cpp:157] Top shape: 10 256 13 13 (432640) I0819 13:01:07.599968 5427 net.cpp:165] Memory required for data: 65519160 I0819 13:01:07.599988 5427 layer_factory.hpp:77] Creating layer relu5 I0819 13:01:07.600002 5427 net.cpp:100] Creating Layer relu5 I0819 13:01:07.600010 5427 net.cpp:434] relu5 <- conv5 I0819 13:01:07.600025 5427 net.cpp:395] relu5 -> conv5 (in-place) I0819 13:01:07.600039 5427 net.cpp:150] Setting up relu5 I0819 13:01:07.600051 5427 net.cpp:157] Top shape: 10 256 13 13 (432640) I0819 13:01:07.600059 5427 net.cpp:165] Memory required for data: 67249720 I0819 13:01:07.600067 5427 layer_factory.hpp:77] Creating layer pool5 I0819 13:01:07.600080 5427 net.cpp:100] Creating Layer pool5 I0819 13:01:07.600088 5427 net.cpp:434] pool5 <- conv5 I0819 13:01:07.600100 5427 net.cpp:408] pool5 -> pool5 I0819 13:01:07.600121 5427 net.cpp:150] Setting up pool5 I0819 13:01:07.600132 5427 net.cpp:157] Top shape: 10 256 6 6 (92160) I0819 13:01:07.600141 5427 net.cpp:165] Memory required for data: 67618360 I0819 13:01:07.600148 5427 layer_factory.hpp:77] Creating layer fc6 I0819 13:01:07.600164 5427 net.cpp:100] Creating Layer fc6 I0819 13:01:07.600172 5427 net.cpp:434] fc6 <- pool5 I0819 13:01:07.600184 5427 net.cpp:408] fc6 -> fc6 I0819 13:01:07.638474 5427 net.cpp:150] Setting up fc6 I0819 13:01:07.638522 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.638533 5427 net.cpp:165] Memory required for data: 67782200 I0819 13:01:07.638556 5427 layer_factory.hpp:77] Creating layer relu6 I0819 13:01:07.638577 5427 net.cpp:100] Creating Layer relu6 I0819 13:01:07.638588 5427 net.cpp:434] relu6 <- fc6 I0819 13:01:07.638603 5427 net.cpp:395] relu6 -> fc6 (in-place) I0819 13:01:07.638628 5427 net.cpp:150] Setting up relu6 I0819 13:01:07.638640 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.638648 5427 net.cpp:165] Memory required for data: 67946040 I0819 13:01:07.638658 5427 layer_factory.hpp:77] Creating layer drop6 I0819 13:01:07.638672 5427 net.cpp:100] Creating Layer drop6 I0819 13:01:07.638682 5427 net.cpp:434] drop6 <- fc6 I0819 13:01:07.638700 5427 net.cpp:395] drop6 -> fc6 (in-place) I0819 13:01:07.638716 5427 net.cpp:150] Setting up drop6 I0819 13:01:07.638728 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.638736 5427 net.cpp:165] Memory required for data: 68109880 I0819 13:01:07.638744 5427 layer_factory.hpp:77] Creating layer fc7 I0819 13:01:07.638757 5427 net.cpp:100] Creating Layer fc7 I0819 13:01:07.638767 5427 net.cpp:434] fc7 <- fc6 I0819 13:01:07.638778 5427 net.cpp:408] fc7 -> fc7 I0819 13:01:07.656704 5427 net.cpp:150] Setting up fc7 I0819 13:01:07.656746 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.656756 5427 net.cpp:165] Memory required for data: 68273720 I0819 13:01:07.656779 5427 layer_factory.hpp:77] Creating layer relu7 I0819 13:01:07.656797 5427 net.cpp:100] Creating Layer relu7 I0819 13:01:07.656806 5427 net.cpp:434] relu7 <- fc7 I0819 13:01:07.656821 5427 net.cpp:395] relu7 -> fc7 (in-place) I0819 13:01:07.656836 5427 net.cpp:150] Setting up relu7 I0819 13:01:07.656844 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.656852 5427 net.cpp:165] Memory required for data: 68437560 I0819 13:01:07.656858 5427 layer_factory.hpp:77] Creating layer drop7 I0819 13:01:07.656870 5427 net.cpp:100] Creating Layer drop7 I0819 13:01:07.656877 5427 net.cpp:434] drop7 <- fc7 I0819 13:01:07.656888 5427 net.cpp:395] drop7 -> fc7 (in-place) I0819 13:01:07.656899 5427 net.cpp:150] Setting up drop7 I0819 13:01:07.656908 5427 net.cpp:157] Top shape: 10 4096 (40960) I0819 13:01:07.656913 5427 net.cpp:165] Memory required for data: 68601400 I0819 13:01:07.656921 5427 layer_factory.hpp:77] Creating layer fc8 I0819 13:01:07.656932 5427 net.cpp:100] Creating Layer fc8 I0819 13:01:07.656939 5427 net.cpp:434] fc8 <- fc7 I0819 13:01:07.656949 5427 net.cpp:408] fc8 -> fc8 I0819 13:01:07.660929 5427 net.cpp:150] Setting up fc8 I0819 13:01:07.660970 5427 net.cpp:157] Top shape: 10 1000 (10000) I0819 13:01:07.660979 5427 net.cpp:165] Memory required for data: 68641400 I0819 13:01:07.661008 5427 layer_factory.hpp:77] Creating layer prob I0819 13:01:07.661025 5427 net.cpp:100] Creating Layer prob I0819 13:01:07.661031 5427 net.cpp:434] prob <- fc8 I0819 13:01:07.661042 5427 net.cpp:408] prob -> prob I0819 13:01:07.661059 5427 net.cpp:150] Setting up prob I0819 13:01:07.661065 5427 net.cpp:157] Top shape: 10 1000 (10000) I0819 13:01:07.661069 5427 net.cpp:165] Memory required for data: 68681400 I0819 13:01:07.661074 5427 net.cpp:228] prob does not need backward computation. I0819 13:01:07.661079 5427 net.cpp:228] fc8 does not need backward computation. I0819 13:01:07.661084 5427 net.cpp:228] drop7 does not need backward computation. I0819 13:01:07.661089 5427 net.cpp:228] relu7 does not need backward computation. I0819 13:01:07.661093 5427 net.cpp:228] fc7 does not need backward computation. I0819 13:01:07.661098 5427 net.cpp:228] drop6 does not need backward computation. I0819 13:01:07.661103 5427 net.cpp:228] relu6 does not need backward computation. I0819 13:01:07.661108 5427 net.cpp:228] fc6 does not need backward computation. I0819 13:01:07.661113 5427 net.cpp:228] pool5 does not need backward computation. I0819 13:01:07.661119 5427 net.cpp:228] relu5 does not need backward computation. I0819 13:01:07.661123 5427 net.cpp:228] conv5 does not need backward computation. I0819 13:01:07.661128 5427 net.cpp:228] relu4 does not need backward computation. I0819 13:01:07.661134 5427 net.cpp:228] conv4 does not need backward computation. I0819 13:01:07.661139 5427 net.cpp:228] relu3 does not need backward computation. I0819 13:01:07.661144 5427 net.cpp:228] conv3 does not need backward computation. I0819 13:01:07.661150 5427 net.cpp:228] norm2 does not need backward computation. I0819 13:01:07.661154 5427 net.cpp:228] pool2 does not need backward computation. I0819 13:01:07.661159 5427 net.cpp:228] relu2 does not need backward computation. I0819 13:01:07.661164 5427 net.cpp:228] conv2 does not need backward computation. I0819 13:01:07.661170 5427 net.cpp:228] norm1 does not need backward computation. I0819 13:01:07.661175 5427 net.cpp:228] pool1 does not need backward computation. I0819 13:01:07.661180 5427 net.cpp:228] relu1 does not need backward computation. I0819 13:01:07.661185 5427 net.cpp:228] conv1 does not need backward computation. I0819 13:01:07.661190 5427 net.cpp:228] data does not need backward computation. I0819 13:01:07.661193 5427 net.cpp:270] This network produces output prob I0819 13:01:07.661209 5427 net.cpp:283] Network initialization done. F0819 13:01:07.709951 5427 upgrade_proto.cpp:86] Check failed: ReadProtoFromBinaryFile(param_file, param) Failed to parse NetParameter file: ../models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel *** Check failure stack trace: *** Aborted
Please, can someone help? I don't know what to do. P.S.: Some usefull infomation: Python version: 2.7.12. IPython version: IPython 2.4.1 -- An enhanced Interactive Python. (If you need anything else, tell me. :))
I've solved this problem. Unfortunately, I don't remember for sure, but I guess it's something to do with deprecated version of the "bvlc_reference_caffenet.caffemodel".