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.legacy_tf_layers' #2372

Closed
2 tasks done
akshatsingh22 opened this issue Sep 9, 2023 · 3 comments
Closed
2 tasks done

ModuleNotFoundError: No module named 'keras.legacy_tf_layers' #2372

akshatsingh22 opened this issue Sep 9, 2023 · 3 comments
Assignees

Comments

@akshatsingh22
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Bug description

ModuleNotFoundError: No module named 'keras.legacy_tf_layers'

Google Colab!

Operating System

operating system: Google Colab

DeepLabCut version

dlc version: 2.3.5

DeepLabCut mode

single animal

Device type

gpu: Nvidia Tesla V100

Steps To Reproduce

from google.colab import drive
drive.mount('/content/drive')

!pip install deeplabcut

import os
import deeplabcut

!unzip 'MyProject.zip'

config_path = '/content/MyProject/config.yaml'

deeplabcut.create_training_dataset(
config_path,
num_shuffles=1,
net_type="resnet_50",
augmenter_type='imgaug'
)

deeplabcut.train_network(config_path,
shuffle=1,
trainingsetindex=0,
gputouse=None,
max_snapshots_to_keep=3,
autotune=False,
displayiters=10,
saveiters=1000,
maxiters=10000,
allow_growth=True)

Relevant log output

/usr/lib/python3.10/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/lib/python3.10/importlib/_bootstrap.py in _find_and_load(name, import_)

/usr/lib/python3.10/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

/usr/lib/python3.10/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/usr/lib/python3.10/importlib/_bootstrap.py in _gcd_import(name, package, level)

/usr/lib/python3.10/importlib/_bootstrap.py in _find_and_load(name, import_)

/usr/lib/python3.10/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'keras.legacy_tf_layers'

Anything else?

No response

Code of Conduct

@seesaw1992
Copy link

I ran into the same problem with Colab.

@n-poulsen
Copy link
Collaborator

Which version of TensorFlow do you have installed (and how did you install DeepLabCut)?

I believe this is an error linked with an incompatible version of Tensorflow being installed. You should install tensorflow version <=2.12, so one easy fix would be running pip install --upgrade "tensorflow<=2.10" (on Google Colab/Windows/Linux machines).

For reference, on Apple computers with M1/M2 chips, you would need to run pip install --upgrade "tensorflow-macos<2.13.0".

@akshatsingh22
Copy link
Author

akshatsingh22 commented Sep 11, 2023

Hi @n-poulsen ,

Many thanks for the clarification. Looks like the above solution worked. Outlining steps for others. The bug came in place as google has updated colab to tensorflow 2.13.0.

from google.colab import drive
drive.mount('/content/drive')
!pip install deeplabcut
!pip install --upgrade "tensorflow<=2.10"

Rest steps same as mentioned in the bug report. Training started after that for me so I would say this issue can be closed. Thanks again for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants