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

No module 'keras.engine' #2993

Closed
lrpalmer27 opened this issue Sep 28, 2023 · 11 comments · May be fixed by #2997
Closed

No module 'keras.engine' #2993

lrpalmer27 opened this issue Sep 28, 2023 · 11 comments · May be fixed by #2997

Comments

@lrpalmer27
Copy link

trying to run the demo file to get started. Running into this error in the mrcnn/model.py file. Has anyone seen this before? I cant seem to find keras.engine to install.

21 import keras.backend as K
 22 import keras.layers as KL

---> 23 import keras.engine as KE
24 import keras.models as KM
26 from mrcnn import utils

ModuleNotFoundError: No module named 'keras.engine'

@453875726
Copy link

Have you found how to solve it?

@lrpalmer27
Copy link
Author

lrpalmer27 commented Oct 10, 2023

I did not solve this issue directly. I think it was regarding an installation error. I made a fork of an MRCNN repo compatible with TF2.0.0+ which works, I have included extra details on all dependency versions I am running (winOS).
https://github.com/lrpalmer27/Mask-RCNN-TF2/tree/iceShipBranch

@Rial-Ali
Copy link

This problem is caused by Keras version, the default requirement.txt does not detect version so you should specify version.
here you can find the edited requirement.txt

@AvivTahar
Copy link

It doesnt solve keras.engine module problem, unfortunately (for me on google colab)

@Rial-Ali
Copy link

What is the problem? can you give me more information? @AvivTahar

@AlicanAKCA
Copy link

I've faced with the same error as well.

You can run these commands which are in the readme.md file. Don't forget to try on colab.

Installation
Clone this repository

Install dependencies

pip3 install -r requirements.txt
Run setup from the repository root directory

 python3 setup.py install
 
python3 samples/coco/coco.py train --dataset= /content/Mask_RCNN/data/ --model=coco

The whole error traceback is here:

/content/Mask_RCNN
/usr/local/lib/python3.10/dist-packages/mask_rcnn-2.1-py3.10.egg/mrcnn/model.py:2359: SyntaxWarning: "is" with a literal. Did you mean "=="?
/usr/local/lib/python3.10/dist-packages/mask_rcnn-2.1-py3.10.egg/mrcnn/model.py:2359: SyntaxWarning: "is" with a literal. Did you mean "=="?
2023-12-02 14:32:17.879174: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-12-02 14:32:17.879225: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-12-02 14:32:17.879261: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-12-02 14:32:17.887311: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-12-02 14:32:19.010510: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/content/Mask_RCNN/samples/coco/coco.py", line 56, in <module>
    from mrcnn import model as modellib, utils
  File "/usr/local/lib/python3.10/dist-packages/mask_rcnn-2.1-py3.10.egg/mrcnn/model.py", line 23, in <module>
ModuleNotFoundError: No module named 'keras.engine'

@Rial-Ali
Copy link

Rial-Ali commented Dec 4, 2023

This problem is caused by Keras version, the default requirement.txt does not detect version so you should specify version. here you can find the edited requirement.txt

Did you try to specify the Keras version?!!!

@benjamincerf57
Copy link

Hello,
I had the same problem with keras.engine, then updated with specified the versions you were mentionning to, and now I have an other ImportError:


ImportError Traceback (most recent call last)
Cell In[1], line 16
14 sys.path.append(ROOT_DIR) # To find local version of the library
15 from mrcnn import utils
---> 16 import mrcnn.model as modellib
17 from mrcnn import visualize
18 # Import COCO config

File c:\Users\benja\anaconda3\Lib\site-packages\mask_rcnn-2.1-py3.11.egg\mrcnn\model.py:20
18 import numpy as np
19 import tensorflow as tf
---> 20 import keras
21 import keras.backend as K
22 import keras.layers as KL

File c:\Users\benja\anaconda3\Lib\site-packages\keras_init_.py:4
1 from future import absolute_import
3 from . import utils
----> 4 from . import activations
5 from . import applications
6 from . import backend

File c:\Users\benja\anaconda3\Lib\site-packages\keras\activations.py:6
4 from . import backend as K
...
---> 15 from collections import Iterable
16 from .utils.generic_utils import Progbar
17 from . import backend as K

ImportError: cannot import name 'Iterable' from 'collections' (c:\Users\benja\anaconda3\Lib\collections_init_.py)

@Rial-Ali
Copy link

ImportError: cannot import name 'Iterable' from 'collections' (c:\Users\benja\anaconda3\Lib\collections__init__.py)

Sorry to hear that.
But I think, your Python Version is wrong.
check your version and downgrade it to 3.4.

@zimoradi76
Copy link

trying to run the demo file to get started. Running into this error in the mrcnn/model.py file. Has anyone seen this before? I cant seem to find keras.engine to install.

21 import keras.backend as K
 22 import keras.layers as KL

---> 23 import keras.engine as KE 24 import keras.models as KM 26 from mrcnn import utils

ModuleNotFoundError: No module named 'keras.engine'

hello, did you solve this issue? how?

@coderboyisongithub
Copy link

how to solve this on google colab?

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

Successfully merging a pull request may close this issue.

8 participants