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

AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects' #116

Open
khaitranhq opened this issue Jun 20, 2021 · 0 comments

Comments

@khaitranhq
Copy link

Versions

mtcnn: 0.1.0
keras: 2.4.3
opencv-python: 4.5.2.54

Error

File "/home/leo/Workspace/global/pbl5/pbl5-api/api/urls.py", line 5, in <module>
    from . import views
  File "/home/leo/Workspace/global/pbl5/pbl5-api/api/views.py", line 15, in <module>
    from ai_models import recog, train
  File "/home/leo/Workspace/global/pbl5/pbl5-api/ai_models/recog.py", line 1, in <module>
    import detect
  File "/home/leo/Workspace/global/pbl5/pbl5-api/detect.py", line 4, in <module>
    from mtcnn import MTCNN
  File "/home/leo/.local/lib/python3.8/site-packages/mtcnn/__init__.py", line 26, in <module>
    from mtcnn.mtcnn import MTCNN
  File "/home/leo/.local/lib/python3.8/site-packages/mtcnn/mtcnn.py", line 37, in <module>
    from mtcnn.network.factory import NetworkFactory
  File "/home/leo/.local/lib/python3.8/site-packages/mtcnn/network/factory.py", line 27, in <module>
    from keras.models import Model
  File "/home/leo/.local/lib/python3.8/site-packages/keras/__init__.py", line 20, in <module>
    from . import initializers
  File "/home/leo/.local/lib/python3.8/site-packages/keras/initializers/__init__.py", line 124, in <module>
    populate_deserializable_objects()
  File "/home/leo/.local/lib/python3.8/site-packages/keras/initializers/__init__.py", line 82, in populate_deserializable_objects
    generic_utils.populate_dict_with_module_objects(
AttributeError: module 'keras.utils.generic_utils' has no attribute 'populate_dict_with_module_objects'

Description

I run the example in Readme and it shows this error. I found out the way to solve it, that's changes import part in mtcnn/network/factory/py from

from keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax
from keras.models import Model

to

from tensorflow.keras.layers import Input, Dense, Conv2D, MaxPooling2D, PReLU, Flatten, Softmax
from tensorflow.keras.models import Model

However, I think it's better if there's a change in the source code.

Thanks in advance!

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

1 participant