Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert to CoreML #8

Open
JakupGuven opened this issue Apr 12, 2019 · 4 comments
Open

Cannot convert to CoreML #8

JakupGuven opened this issue Apr 12, 2019 · 4 comments

Comments

@JakupGuven
Copy link

I used this https://github.com/qqwweee/keras-yolo3 to convert my model trained using Darknet to a Keras model.
I'm trying to convert it to CoreML but get errors. I think it would be very good if you could specify how your virtualenv looks like when you do this @Ma-Dan

The error I get:

tf.estimator package not installed.
tf.estimator package not installed.
Traceback (most recent call last):
File "coreml.py", line 3, in
coreml_model = coremltools.converters.keras.convert('Doors.h5', input_names='input1', image_input_names='input1', output_names=['output1', 'output2', 'output3'], image_scale=1/255.)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/coremltools/converters/keras/_keras_converter.py", line 760, in convert
custom_conversion_functions=custom_conversion_functions)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/coremltools/converters/keras/_keras_converter.py", line 537, in convertToSpec
custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/coremltools/converters/keras/_keras_converter.py", line 168, in _convert
model = _keras.models.load_model(model, custom_objects = custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/models.py", line 142, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/models.py", line 193, in model_from_config
return layer_from_config(config, custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/utils/layer_utils.py", line 40, in layer_from_config
custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/engine/topology.py", line 2582, in from_config
process_layer(layer_data)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/engine/topology.py", line 2560, in process_layer
custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/utils/layer_utils.py", line 42, in layer_from_config
return layer_class.from_config(config['config'])
File "/home/jakup/Utilities/coreml/local/lib/python2.7/site-packages/keras/engine/topology.py", line 1025, in from_config
return cls(**config)
TypeError: init() got an unexpected keyword argument 'dtype'

@JakupGuven
Copy link
Author

I can add that I'm trying to convert a YOLOv3-tiny model

@Ma-Dan
Copy link
Owner

Ma-Dan commented Apr 13, 2019

I used python 3.6.5 with
Keras 2.1.6
tensorflow 1.5.0
coremltools 2.0
Convert with tensorflow 1.12.0 and Keras 2.2.4 will get errors like
ImportError: cannot import name relu6.
TypeError('Keyword argument not understood:', kwarg)

@JakupGuven
Copy link
Author

@Ma-Dan Do you use the keras-yolo3 repo to convert from Darknet to Keras?
If so how does that virtualenv look?

@JakupGuven
Copy link
Author

Okay @Ma-Dan. I installed a fresh Python 3.6.5 from here: https://www.python.org/downloads/release/python-365/

You can see in the image I attach that I have the versions of tensorflow, keras and coremltools that you specified.
Screenshot from 2019-04-13 13-59-13

I created a virtualenv and installed dependencies with correct versions and I get this error message:
Traceback (most recent call last):
File "coreml.py", line 3, in
coreml_model = coremltools.converters.keras.convert('Doors.h5', input_names='input1', image_input_names='input1', output_names=['output1', 'output2', 'output3'], image_scale=1/255.)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 752, in convert
custom_conversion_functions=custom_conversion_functions)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/coremltools/converters/keras/_keras_converter.py", line 550, in convertToSpec
custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/coremltools/converters/keras/_keras2_converter.py", line 197, in _convert
model = _keras.models.load_model(model, custom_objects = custom_objects)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/models.py", line 270, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/models.py", line 347, in model_from_config
return layer_module.deserialize(config, custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 144, in deserialize_keras_object
list(custom_objects.items())))
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/engine/topology.py", line 2525, in from_config
process_layer(layer_data)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/engine/topology.py", line 2511, in process_layer
custom_objects=custom_objects)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 146, in deserialize_keras_object
return cls.from_config(config['config'])
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/engine/topology.py", line 1271, in from_config
return cls(**config)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/layers/convolutional.py", line 1806, in init
super(UpSampling2D, self).init(**kwargs)
File "/home/jakup/Utilities/coreml/lib/python3.6/site-packages/keras/engine/topology.py", line 293, in init
raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'interpolation')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants