I'm trying to convert a caffemodel file with the coremltools, and get the following:
>>> import coremltools
>>> coreml_model = coremltools.converters.caffe.convert(('model.caffemodel','deploy.prototxt','mean.binaryproto'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 130, in convert
predicted_feature_name)
File "/Library/Python/2.7/site-packages/coremltools/converters/caffe/_caffe_converter.py", line 144, in _export
raise RuntimeError('Unable to load Caffe converter library.')
RuntimeError: Unable to load Caffe converter library.
I installed coremltools with pip:
sudo pip install --ignore-installed six coremltools
I was getting pip errors with the six package, hence the extra argument. The documentation doesn't say I need an additional packages for caffe. Even the example code in the documentation:
mport coremltools
# Convert a caffe model to a classifier in Core ML
coreml_model = coremltools.converters.caffe.convert(('bvlc_alexnet.caffemodel', 'deploy.prototxt'), predicted_feature_name='class_labels.txt' )
failes to run with this error.
You are using the wrong version of Python (and possibly Keras).
It is best if you create a virtualenv and install the dependencies in there:
virtualenv -p /usr/bin/python2.7 env
source env/bin/activate
pip install tensorflow
pip install keras==1.2.2
pip install coremltools
Notice that I'm specifying "-p /usr/bin/python2.7" so that the virtualenv uses the system Python, not whatever other Python you have installed.