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

Error trying to convert model to CoreML #69

Open
raulsf6 opened this issue Jan 20, 2021 · 4 comments
Open

Error trying to convert model to CoreML #69

raulsf6 opened this issue Jan 20, 2021 · 4 comments

Comments

@raulsf6
Copy link

raulsf6 commented Jan 20, 2021

Hi, first of all, thanks for you amazing.

I'm facing an error trying to convert tiny-yolo to CoreML suing the procedures explained in the repo. I manage to get the .h5 representation but when I try to export it to CoreML I get this error:

Traceback (most recent call last):
  File "coreml.py", line 17, in <module>
    coreml_model.input_description['image'] = 'Input image'
  File "/home/rsanchez/.local/share/virtualenvs/Convert-r3iBw4lK/lib/python2.7/site-packages/coremltools/models/model.py", line 79, in __setitem__
    raise AttributeError("No feature with name %s." % key)
AttributeError: No feature with name image.

Could it be due to package versions? I have a virtual Python 3 environment for the Darknet -> Keras transformation and another Python 2.7 environment for the Keras -> CoreML transformation. The only pinned version is Keras but I suppose tensorflow has to be 1.x version. Actually, my packages versions are:

  • Tensorflow 1.15.0
  • Keras 1.2.2
  • coremltools 4.0
  • Python 2.7
@raulsf6 raulsf6 changed the title Error trying to converto model Error trying to convert model to CoreML Jan 20, 2021
@hollance
Copy link
Owner

It's probably the coremltools version (I think I used version 2.0 for this or perhaps even 1.0), but the error is that your model does not have an input named 'image'.

@raulsf6
Copy link
Author

raulsf6 commented Jan 20, 2021

@hollance thanks for your answer! I'll try with those coremltools versions. Could you also tell me which h5py version you used? I think the problem could be when exporting from Darknet to Keras. The h5 model looks like this in Netron:

image

So maybe the first transformation is messing up the input/output names?

@hollance
Copy link
Owner

Just rename the input in the code from image to input_1. It should work then. The name of the input isn't very important.

@raulsf6
Copy link
Author

raulsf6 commented Jan 21, 2021

@hollance, I just managed to execute CoreML.py succesfuly with this packages versions without modifying any code:

keras==1.2.2
tensorflow==1.15.0
coremltools==2.0
h5py

From Darknet to Keras everything works as long as yo use Keras 1.2.2 and Tensorflow 1.x.

Maybe it would be a good idea to update scripts to new versions, specially coreml.py because Python2.7 has no longer support.

Amazing work with this repo!

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