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

Unexpected error (it did work in June2022): cannot import name 'multi_gpu_model' from 'tensorflow.keras.utils' #264

Open
dsubarroca opened this issue Jul 9, 2023 · 1 comment

Comments

@dsubarroca
Copy link

Before filing a report consider the following two questions:

Have you followed all Readme instructions exactly?

Have you checked the troubleshooting section?

Have you looked for similar issues?

Once you are familiar with the code, you're welcome to modify it. Please only continue to file a bug report if you encounter an issue with the provided code and after having followed the instructions.

If you have followed the instructions exactly, couldn't solve your problem with the provided troubleshooting tips and would still like to file a bug or make a feature requests please follow the steps below.

  1. It must be a bug, a feature request, or a significant problem with the documentation (for small docs fixes please send a PR instead).
  2. Every section of the form below must be filled out.

Readme

  • I have followed all Readme instructions carefully: Yes, I did it in June 2022 and worked fine, for sure. I was able to train my own dataset. But in July 2023, when I try to train another custom model (for my son, I'm introducing him to YOLO...", suddendly it doesn't work as it did in June2022

Troubleshooting Section

  • I have looked at the troubleshooting section: ** Yes, nothing related with current issue **

Troubleshooting Section

  • I have looked for similar issues: Yes no issues related to that. The point is that I tried your code in June 2022 and it worked properly. Maybe the issue is related with some tensorflow or keras recent release change that does not allow importing tensorflow.keras.utils multi_gpu_model

System information

  • What is the top-level directory of the model you are using: The root, I'm just testing the Minimal_example, no changes done
  • Have I written custom code (as opposed to using a stock example script provided in the repo): NO
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): running in Google Colab
  • TensorFlow version (use command below): 2.12.0
  • CUDA/cuDNN version: Google Colab free release
  • GPU model and memory: Google Colab free release
  • Exact command to reproduce: running 3_Inference/Detector.py

You can obtain the TensorFlow version with

python -c "import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)"
tensorflow 2.12.0

Describe the problem

Before creating and training my own dataset, I'm following step-by-step example "Minimal_Example.py".
The point is that I get this error just in the third step, when testing the model with Detector.py:

Source code / logs

This is the logs of the "Minimal_Example.py" code, after running the third step of that example.
3_Inference/Detector.py

2023-07-09 18:07:38.247304: 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 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-07-09 18:07:39.113038: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
File "/content/TrainYourOwnYOLO/3_Inference/Detector.py", line 21, in
from keras_yolo3.yolo import YOLO, detect_video, detect_webcam
File "/content/TrainYourOwnYOLO/2_Training/src/keras_yolo3/yolo.py", line 18, in
from tensorflow.keras.utils import multi_gpu_model
ImportError: cannot import name 'multi_gpu_model' from 'tensorflow.keras.utils' (/usr/local/lib/python3.10/dist-packages/keras/api/_v2/keras/utils/init.py)

@AntonMu
Copy link
Owner

AntonMu commented Jul 9, 2023

This is only tested for tensorflow 2.3 and Keras 2.4. Try installing that. Tbh all of this is pretty dated now and you may be better off finding a more recent repo.

This repo let's you train a custom image detector using the state-of-the-art YOLOv3 computer vision algorithm. For a short write up check out this medium post. This repo works with TensorFlow 2.3 and Keras 2.4.

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

2 participants