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 import name relu6 #282

Closed
zantism opened this Issue Oct 26, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@zantism
Copy link

zantism commented Oct 26, 2018

traceback (after attempting to convert custom MobileNet model)

Traceback (most recent call last):
  File "coremlconverte2r.py", line 42, in <module>
    class_labels=class_labels)
  File "/Users/user147784/Library/Python/2.7/lib/python/site-packages/coremltools/converters/keras/_keras_converter.py", line 752, in convert
    custom_conversion_functions=custom_conversion_functions)
  File "/Users/user147784/Library/Python/2.7/lib/python/site-packages/coremltools/converters/keras/_keras_converter.py", line 534, in convertToSpec
    from . import _keras2_converter
  File "/Users/user147784/Library/Python/2.7/lib/python/site-packages/coremltools/converters/keras/_keras2_converter.py", line 14, in <module>
    from . import _layers2
  File "/Users/user147784/Library/Python/2.7/lib/python/site-packages/coremltools/converters/keras/_layers2.py", line 10, in <module>
    from keras_applications.mobilenet import relu6
ImportError: cannot import name relu6

Tried the following solution

from keras.utils.generic_utils import CustomObjectScope
with CustomObjectScope({'relu6': keras.applications.mobilenet.relu6,'DepthwiseConv2D': keras.applications.mobilenet.DepthwiseConv2D}):

Still received error

WARNING:root:Keras version 2.2.4 detected. Last version known to be fully compatible of Keras is 2.1.6 .
WARNING:root:TensorFlow version 1.11.0 detected. Last version known to be fully compatible is 1.5.0 .
Traceback (most recent call last):
  File "coremlconverte2r.py", line 12, in <module>
    with CustomObjectScope({'relu6': keras.applications.mobilenet.relu6,'DepthwiseConv2D': keras.applications.mobilenet.DepthwiseConv2D}):
AttributeError: 'module' object has no attribute 'relu6'

Have not even the slightest of idea whats causing this.

@aseemw

This comment has been minimized.

Copy link
Collaborator

aseemw commented Oct 27, 2018

Whats the version of Keras installed on your system?
Can you build from top of master and try again?
This error should be resolved after PR #278 went in.

@zantism

This comment has been minimized.

Copy link
Author

zantism commented Oct 27, 2018

Latest version of keras (2.2.4)
Currently on a virtual mac environment so it has python 2.7.10 and 3.7

Trying to build from master, not familiar with Cmake

Would correct statement be:
cmake . DPYTHON=$(python)

@aseemw

This comment has been minimized.

Copy link
Collaborator

aseemw commented Oct 27, 2018

Just execute these commands:

git clone https://github.com/apple/coremltools.git
cd coremltools
cmake . -DPYTHON=$(which python) -DPYTHON_CONFIG=$(which python-config)
make
pip install -e .
@zantism

This comment has been minimized.

Copy link
Author

zantism commented Oct 27, 2018

Thanks for the help.

for anyone else this will do the trick also
pip install -U https://github.com/apple/coremltools/archive/master.zip --user

@zantism zantism closed this Oct 27, 2018

@adib

This comment has been minimized.

Copy link

adib commented Dec 26, 2018

@zantism Using pip install would omit the native libraries used by Core ML. Recompiling from source is a better option.

Also take note of #295 (missing MLFeatureTypeSequence symbol) when building from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.