I failed to convert caffe model into mlmodel using coremltools 5

Viewed 106

I try to convert caffe model. I am using coremltools v5. this is my code

import coremltools

caffe_model = ('oxford102.caffemodel', 'deploy.prototxt')

labels = 'flower-labels.txt'

coreml_model = coremltools.converters.caffe.convert(
    caffe_model,
    class_labels=labels,
    image_input_names='data'
)

coreml_model.save('FlowerClassifier.mlmodel')

I convert using below command

python3 convert-script.py

And i get an error message like below.

error message

Does anybody face this problem and have solution on it?

2 Answers

I just came across this as I was having the same problem. The caffe support is not available in the newer versions of coremltools API. To make this code run an older version of coremltools (such as 3.4) must be used, which requires using Python 2.7 - which is best done in a virtual environment. I assume you've solved your issue already, but I added this in case anyone else stumbles onto this question.

There are several solutions according to your case:

  1. I had the same issue on my M1 Mac. You can resolve the same by duplicating your Terminal, and running it with Rosetta.(This worked for me)

cd ~/.virtualenvs/<your venv name here>/bin
mkdir bk; cp python bk; mv -f bk/python .;rmdir bk
codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f python

Fore more solutions and issue you can watch this issue on github

Related