import efficientnet.keras as efn – AttributeError: module ‘keras.utils’ has no attribute ‘generic_utils’

I am trying to use EfficientNet from

So, I installed this via pip:

!pip install git+

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/ in init_keras_custom_objects()
     69     }
---> 71     keras.utils.generic_utils.get_custom_objects().update(custom_objects)

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?


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