module 'keras.utils' has no attribute 'generic_utils'
See original GitHub issueHi,
I’m trying to run multiclass segmentation (camvid).ipynb example and get an error after running the following block:
import segmentation_models as sm
Here is the error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-28-93aee672c619> in <module>
----> 1 import segmentation_models as sm
2
3 # segmentation_models could also use `tf.keras` if you do not have Keras installed
4 # or you could switch to other framework using `sm.set_framework('tf.keras')`
E:\PycharmProjects\Autometrics\Spattering_segmentation\segmentation_models\__init__.py in <module>
----> 1 from .segmentation_models import *
E:\PycharmProjects\Autometrics\Spattering_segmentation\segmentation_models\segmentation_models\__init__.py in <module>
96 _framework = os.environ.get('SM_FRAMEWORK', _DEFAULT_KERAS_FRAMEWORK)
97 try:
---> 98 set_framework(_framework)
99 except ImportError:
100 other = _TF_KERAS_FRAMEWORK_NAME if _framework == _KERAS_FRAMEWORK_NAME else _KERAS_FRAMEWORK_NAME
E:\PycharmProjects\Autometrics\Spattering_segmentation\segmentation_models\segmentation_models\__init__.py in set_framework(name)
66 if name == _KERAS_FRAMEWORK_NAME:
67 import keras
---> 68 import efficientnet.keras # init custom objects
69 elif name == _TF_KERAS_FRAMEWORK_NAME:
70 from tensorflow import keras
~\AppData\Roaming\Python\Python37\site-packages\efficientnet\keras.py in <module>
15 preprocess_input = inject_keras_modules(model.preprocess_input)
16
---> 17 init_keras_custom_objects()
~\AppData\Roaming\Python\Python37\site-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'
Can anyone help me to solve this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:34 (1 by maintainers)
Top Results From Across the Web
module 'tensorflow.python.keras.utils.generic_utils' has no ...
I encountered the same problem using Python 3.9 and Tensorflow 2.5. The problem for me was that those two are not yet compatible,...
Read more >[PY 4] module 'keras.utils.generic_utils' has no attribute ...
Remove the errors: AttributeError: module ' keras. utils. generic_utils ' has no attribute 'populate_dict_with_module_objects'Replace from ...
Read more >Module: tf.keras.utils | TensorFlow v2.11.0
class CustomObjectScope : Exposes custom classes/functions to Keras deserialization internals. class GeneratorEnqueuer : Builds a queue out ...
Read more >I'm getting this error in Python AttributeError: module 'keras. ...
I'm getting this error in Python. AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'. Please help.
Read more >解决AttributeError: module 'keras.utils.generic_utils' has no ...
问题:使用keras 2.2.4和tensorflow2.5组合时,import keras出现错误AttributeError: module 'keras.utils.generic_utils' has no attribute ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
I changed
keras.utils.generic_utils.get_custom_objects().update(custom_objects)tokeras.utils.get_custom_objects().update(custom_objects)in.../lib/python3.6/site-packages/efficientnet/__init__.pyand it solved the issue.