0

I am trying to compile and run the snippets posted here, which basically is going to let me visualize the network internals (feature maps).

I have successfully compiled caffe and pycaffe using the caffe-windows branch, And I have copied the caffe folder, into T:\Anaconda\Lib\site-packages folder. Yet still, when I try to run this snippet of code in Jupyter notebook:

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

# Make sure that caffe is on the python path:
caffe_root = 'TC:/Caffe/'  # this file is expected to be in {caffe_root}/examples
import sys
sys.path.insert(0, caffe_root + 'python')

import caffe

plt.rcParams['figure.figsize'] = (10, 10)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'

import os
if not os.path.isfile(caffe_root + 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'):
    print("Downloading pre-trained CaffeNet model...")
    !../scripts/download_model_binary.py ../models/bvlc_reference_caffenet

I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-e7a8ec94e861> in <module>()
      8 sys.path.insert(0, caffe_root + 'python')
      9 
---> 10 import caffe

L:\Anaconda2\lib\site-packages\caffe\__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver
      2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver
      3 from .proto.caffe_pb2 import TRAIN, TEST
      4 from .classifier import Classifier
      5 from .detector import Detector

L:\Anaconda2\lib\site-packages\caffe\pycaffe.py in <module>()
     11 import numpy as np
     12 
---> 13 from ._caffe import Net, SGDSolver
     14 import caffe.io
     15 

ImportError: DLL load failed: The specified module could not be found.

What's wrong here?

Note: I'm using Anaconda2-2.4.1-Windows-x86_64.exe.

halfer
  • 19,824
  • 17
  • 99
  • 186
Hossein
  • 24,202
  • 35
  • 119
  • 224
  • see: http://stackoverflow.com/questions/34763915/pycaffe-installation-in-windows – Shai Jan 18 '16 at 11:47
  • since you add `caffe_root + '/python'` manually into your `path` I don't suppose you need to copy the module to `site_packages`. – Shai Jan 18 '16 at 11:48
  • @Shai: Thanks, But there is nothing special about the first link! couldnt find any information in that! so you mean is it redundant? If so, why in first place its declared like that? – Hossein Jan 18 '16 at 12:13

1 Answers1

1

There's most likely a more specific dependency issue you are not seeing (Protobuf / OpenCV). First try using the C++ API to load an example and make sure all the DLL's load. Then you can more confidently narrow things down to the Python side. I recommend the more recent windows caffe instructions based off the branch you're using:

https://initialneil.wordpress.com/2015/01/11/build-caffe-in-windows-with-visual-studio-2013-cuda-6-5-opencv-2-4-9/

I had to do a complete rebuild as detailed above (note that some dependencies are easier to find with NuGet). Also be on the lookout for the right protobuf binaries in various 3rdParty.zip files throughout the above blog.

If you are okay with a snapshot version of Caffe and you don't need to modify the project itself, the following binaries are much easier to install and get working:

https://initialneil.wordpress.com/2015/07/15/caffe-vs2013-opencv-in-windows-tutorial-i/

crizCraig
  • 8,487
  • 6
  • 54
  • 53
  • Thanks,I'll check this an report back. Altough I'm pretty sure the OpenCV is got to be fine, Im not sure about the proto buff though!) – Hossein Jan 19 '16 at 06:02
  • 1
    you were right, protbuf was missing, I had to compile the protobuf package for anaconda and then the error is gone ;) by the way whats the meaning of this line? I'm not good with python, Thanks again ` !../scripts/download_model_binary.py ../models bvlc_reference_caffenet ` is `!` an operator or something? – Hossein Jan 19 '16 at 07:17
  • 1
    I think that's Jupyter syntax to start a process. Perhaps try Python `subprocess` or just manually run it :) – crizCraig Jan 19 '16 at 20:19