-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Support exports for Apple's new mlmodel format in Keras 2 #7007
Comments
Hi, @gsabran! I spent a few minutes reviewing their code. It appears that it would not take much effort to update their tool to use Keras 2 models. I saw two major issues: naming changes and parameter order changes. A guide to updating to Keras 2 is available from the changelog. In addition, because Keras currently provides models with weights in a popular interchange format (HDF5) and models without weights in additional two popular interchange formats (JSON and YAML) it seems like the burden should be on the external library (especially when the external library transforms a model available in an easily read format to an unreadable format). |
(As an aside, it is noteworthy that CoreML is using the TensorFlow backend but doesn't mention TensorFlow support on their website. I feel like this would be a feature you'd want to emphasize!) |
Yes they don't have direct support for TF... I 100% agree that the burden should be on Apple and I'm quite disappointed to not see this in what has been released, especially as you've mentioned since Keras supports standard formats. Now, assuming that they won't do it soon (which they actually might since they've done a first step by supporting a subset of popular frameworks and it's still early in CoreML days) I'm looking for the best way forward. I'll have a look at the changelogs and see if I can get a good grasp on what changes are required. |
Actually they might be working on it: https://forums.developer.apple.com/thread/79505 |
Keras 2.0 support is already there (released yesterday), with coremltools v.0.4.0 Also, refer to newest comments on Apple Developer Forums |
import coremltools it returns: AttributeError: 'module' object has no attribute 'convert', |
same problem here as above: AttributeError: 'module' object has no attribute 'convert' |
I've created a very simple Sequential Linear Regression model and my coremltools export is failing with this error message: 'module' object has no attribute 'mobilenet' @Fenoms @jbmaxwell have you solved your issues ? |
@JacopoMangiavacchi I had the same problem. I fixed by installing the latest coremltools version with the latest supported keras version. 0.6.3 coremltools with keras 2.0.6 worked for me |
I'm having the same problem. Python 2.7.13, Keras 2.0.8 and coremltools 0.6.3 are installed:
any ideas? |
@kinergy I had the same problem. I fixed by installing the latest tensorflow version 1.3.0. |
@tatsuya-ogawa Thanks mate, that fixed for me. Apparently I didn't had tensorflow installed for python2.7. |
|
For me downgrading keras to 2.1.6 fixed it. |
I had to install Keras, Tensorflow again and that error seemed to disappear. In my case it happened because one of the components(tensorflow) was missing. |
Actually, it is because Coremltools only works with Python2, so you need to install Keras and Tensorflow on python2 too by typing: I hope this helps, at least it worked for me. |
Apple's recently announced support for ML models in iOS11 through a specific format. (WWC17 video, docs)
They provide an opensource conversion python package called coremltools that currently only support conversion from Keras 1.2.2 models. (see in the version of the package I hosted). They seem to expect the open source community to implement conversion from other formats...
Is there any plan from Keras to do so? Else what do you suggest? The code for Keras 1.2.2 is roughly 2000 lines. I guess there's probably a bunch of things that can be reused to support conversion from Keras 2, but I don't have the expertise around Keras's model saving format to make a PR :(
I tried to load a model saved by Keras 2 with coremltools and that failed.
I also opened a question on SO and hosted the package code on github to make the discussion easier: https://github.com/gsabran/coremltools
Extending the save API to something like
save(self, filepath, overwrite=True, include_optimizer=True, format='keras' or 'mlmodel')
would be great.The text was updated successfully, but these errors were encountered: