Reputation: 1508
I am trying to use EfficientNet from https://github.com/qubvel/segmentation_models.
So, I installed this via pip:
!pip install git+https://github.com/qubvel/segmentation_models
Then I tried to import efficientnet.keras
:
import efficientnet.keras as efn
And got this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-57-61d736540c72> in <module>()
----> 1 import efficientnet.keras as efn
1 frames
/usr/local/lib/python3.6/dist-packages/efficientnet/__init__.py in init_keras_custom_objects()
69 }
70
---> 71 keras.utils.generic_utils.get_custom_objects().update(custom_objects)
72
73
AttributeError: module 'keras.utils' has no attribute 'generic_utils'
This is very strange since it worked yesterday without any problems and today in one notebook as well but in the other ones I got this error. Does anyone know what to do?
Upvotes: 2
Views: 7319
Reputation: 11
!pip install tensorflow==2.1.0
!pip install keras==2.3.1
!pip install segmentation-models
Try this it worked for me on google colab
Upvotes: 1
Reputation: 65
You may still use tensorflow 2.4.1 with segmentation models v. 1.0.1.
get_custom_objects()
was moved from keras.utils.generic_utils
to keras.utils
.
You can make:
keras.utils.generic_utils = keras.utils
And only after that you can import segmentation models
.
This is not 100% safe solution but in my case it works perfectly.
Upvotes: 1
Reputation: 100
It seems for me that you are using Colab and they have probably upgraded some packages today, so we got the same error. I solved that issue by downgrading the Keras and Tenserflow packages to the previous ones (I have only guessed the version numbers) via:
!pip install q tensorflow==2.1
!pip install q keras==2.3.1
Upvotes: 1