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

ModuleNotFoundError: No module named 'keras.src.engine' #5856

Open
plowman opened this issue Feb 12, 2025 · 1 comment
Open

ModuleNotFoundError: No module named 'keras.src.engine' #5856

plowman opened this issue Feb 12, 2025 · 1 comment
Assignees
Labels
os:macOS Issues on MacOS stat:awaiting response Waiting for user response task:object detection Issues related to Object detection: Track and label objects in images and video. type:bug Bug in the Source Code of MediaPipe Solution type:modelmaker Issues related to creation of custom on-device ML solutions

Comments

@plowman
Copy link

plowman commented Feb 12, 2025

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

No

OS Platform and Distribution

macOS 15.3

Mobile device if the issue happens on mobile device

No response

Browser and version if the issue happens on browser

No response

Programming Language and version

Python 3.11

MediaPipe version

0.10.21

Bazel version

No response

Solution

Model Maker

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

Importing from mediapipe_model_maker import object_detector raises an exception

Describe the expected behaviour

Importing should not raise an exception

Standalone code/steps you may have used to try to get what you need

pip install mediapipe-model-maker==0.2.1.3 && python -c "from mediapipe_model_maker import object_detector"

Other info / Complete Logs

  • There is a similar issue (ModuleNotFoundError: No module named 'keras.src.engine' #5229) that was closed. I'm creating a new issue here because it seems the issue has resurfaced.
    • Also, the workaround suggested in the other issue, pip install 'keras<3.0.0' mediapipe-model-maker, fails with a dependency conflict.
  • pip install mediapipe-model-maker==0.2.1.4 fully fails to run, which is why I show the example using 0.2.1.3.

Repro Steps

python3.11 -m venv .venv
source .venv/bin/activate
pip install mediapipe-model-maker==0.2.1.3
python -c "from mediapipe_model_maker import object_detector"

Full error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/project/.venv/lib/python3.11/site-packages/mediapipe_model_maker/__init__.py", line 22, in <module>
    from mediapipe_model_maker.python.text import text_classifier
  File "/project/.venv/lib/python3.11/site-packages/mediapipe_model_maker/python/text/text_classifier/__init__.py", line 20, in <module>
    from mediapipe_model_maker.python.text.text_classifier import text_classifier
  File "/project/.venv/lib/python3.11/site-packages/mediapipe_model_maker/python/text/text_classifier/text_classifier.py", line 22, in <module>
    from tensorflow_addons import optimizers as tfa_optimizers
  File "/project/.venv/lib/python3.11/site-packages/tensorflow_addons/__init__.py", line 23, in <module>
    from tensorflow_addons import activations
  File "/project/.venv/lib/python3.11/site-packages/tensorflow_addons/activations/__init__.py", line 17, in <module>
    from tensorflow_addons.activations.gelu import gelu
  File "/project/.venv/lib/python3.11/site-packages/tensorflow_addons/activations/gelu.py", line 19, in <module>
    from tensorflow_addons.utils.types import TensorLike
  File "/project/.venv/lib/python3.11/site-packages/tensorflow_addons/utils/types.py", line 29, in <module>
    from keras.src.engine import keras_tensor
ModuleNotFoundError: No module named 'keras.src.engine'
@plowman plowman added the type:bug Bug in the Source Code of MediaPipe Solution label Feb 12, 2025
@kuaashish kuaashish assigned kuaashish and unassigned kalyan2789g Feb 12, 2025
@kuaashish kuaashish added os:macOS Issues on MacOS type:modelmaker Issues related to creation of custom on-device ML solutions task:object detection Issues related to Object detection: Track and label objects in images and video. labels Feb 12, 2025
@kuaashish
Copy link
Collaborator

Hi @plowman,

We are aware of the issue you mentioned regarding installation on macOS (Silicon-based) and Windows, caused by

tensorflow/text

no longer supporting these platforms. You can find further details in the related issue reported here. Currently, installation is only supported for version 3.9, and it can be done as outlined below.

pip install "pyyaml>6.0.0" "keras<3.0.0" "tensorflow<2.16" "tf-models-official<2.16" mediapipe-model-maker --no-deps

We successfully installed Mediapipe Model Maker version 0.2.1.3 without any dependency issues and were able to import from "mediapipe_model_maker import object_detector" without errors, as shown in the attached screenshot. However, when using the virtual environment created, the import fails, while it works outside of the environment.

Image

We suggest trying a similar approach if it suits your needs. Please let us know if we can assist further.

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:macOS Issues on MacOS stat:awaiting response Waiting for user response task:object detection Issues related to Object detection: Track and label objects in images and video. type:bug Bug in the Source Code of MediaPipe Solution type:modelmaker Issues related to creation of custom on-device ML solutions
Projects
None yet
Development

No branches or pull requests

3 participants