Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I failed to convert caffe model into mlmodel using coremltools 5

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?

like image 771
bhay Avatar asked Feb 22 '26 05:02

bhay


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.

like image 167
Scott McIntosh Avatar answered Feb 25 '26 02:02

Scott McIntosh


I had the same error running python 3.7

In the virtualenv, solution is to run:

pip install coremltools==3.0

Don't have to change python versions and just rerun the script

like image 34
sschwab Avatar answered Feb 25 '26 01:02

sschwab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!