1

While trying convert caffemodel to mlmodel i cant run my converter-script.py this is my converter-script.py file :

import coremltools
caffe_model = ('oxford102.caffemodel', 'deploy.prototxt')
labels = 'flower-labels.txt'
models = coremltools.converters.caffe.converts(
   caffe_model,
   class_labels = labels,
   image_input_names = 'data'
)
coreml_model.save('FlowerClassifier.mlmodel')

i run this using virtualenv with python 2.7 and i get this error message :

File "convert-script.py", line 1, in import coremltools File "/Users/aji/Documents/Environments/python27/lib/python2.7/site-packages/coremltools/init.py", line 28, in _root_logger_handlers_backup = _root_logger.handlers.copy() AttributeError: 'list' object has no attribute 'copy'

Anyone can give me solution?

2 Answers2

0

Use python3 instead of creating and running from a python27 venv.

python3 convert-script.py

worked for me

lordvidex
  • 3,581
  • 3
  • 17
  • 25
0

So the problem here is about coremltools. The most recent version of it works with python 3 and you're doing conversion on python 2.7

The easiest way to solve your problem is to downgrade your coremltools to version, which works with py2.7, you can do it with following command in your terminal:

pip install coremltools=4.0    

Then just run script the same way you did it before :)