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 'convert_all_kernels_in_model' from 'tensorflow.python.keras.utils' #494

Closed
aliavni opened this issue Mar 1, 2020 · 4 comments

Comments

@aliavni
Copy link

aliavni commented Mar 1, 2020

Hi,

I am trying to import ModelTraining with from imageai.Prediction.Custom import ModelTraining and I get the following error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File ".../python3.7/site-packages/imageai/Prediction/Custom/__init__.py", line 4, in <module>
    from ..DenseNet.densenet import DenseNetImageNet121
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File ".../python3.7/site-packages/imageai/Prediction/DenseNet/densenet.py", line 21, in <module>
    from tensorflow.python.keras.utils import convert_all_kernels_in_model
ImportError: cannot import name 'convert_all_kernels_in_model' from 'tensorflow.python.keras.utils' (.../python3.7/site-packages/tensorflow_core/python/keras/utils/__init__.py)

This issue gets resolved when I update all tensorflow.python.keras imports with tensorflow.keras in ImageAI library. For example, I change from tensorflow.python.keras.utils import convert_all_kernels_in_model to from tensorflow.keras.utils import convert_all_kernels_in_model.

Is there a specific tensorflow version ImageAI requires?

Here is some info about my environment:

Python 3.6.10
imageai==2.1.5
tensorflow==2.1.0
Keras==2.3.1

@harshithere
Copy link

harshithere commented Mar 6, 2020

Currently, ImageAI works on tensorflow version 1.14 (and higher) but is not compactible with 2.0 or higher. Thats the reason you face this issue. Try downgrading your tensorflow version.
I faced similar issues and the downgrade helped

@aliavni
Copy link
Author

aliavni commented Mar 6, 2020

Thanks @harshithere. Closing this issue now.

@aliavni aliavni closed this as completed Mar 6, 2020
@400lbhacker
Copy link

on colab... at the following magic line at the begining of your code cell
%tensorflow_version 1.x

@ekesdf
Copy link

ekesdf commented Nov 24, 2021

Update tf to 2.4.0 and it will work and just comment out the line this should help

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

4 participants