OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.63k stars 2.19k forks source link

Training doesn't work -- error -- "no attribute 'tf2'" #678

Open SB2020-eye opened 3 years ago

SB2020-eye commented 3 years ago

I am trying to run training for custom object detection.

I get the following:

(imageai) C:\users\scott\desktop\python2>python imageai_train_detection_models.py
2021-06-17 08:24:33.226689: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-06-17 08:24:33.227561: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "imageai_train_detection_models.py", line 3, in <module>
    from imageai.Detection.Custom import DetectionModelTrainer
  File "C:\ProgramData\Miniconda3\envs\imageai\lib\site-packages\imageai\Detection\__init__.py", line 17, in <module>
    from imageai.Detection.YOLO.utils import letterbox_image, yolo_eval, preprocess_input, retrieve_yolo_detections, draw_boxes
  File "C:\ProgramData\Miniconda3\envs\imageai\lib\site-packages\imageai\Detection\YOLO\utils.py", line 2, in <module>
    from keras import backend as K # Should this become from tensorflow import keras as K?
  File "C:\ProgramData\Miniconda3\envs\imageai\lib\site-packages\keras\__init__.py", line 20, in <module>
    from . import initializers
  File "C:\ProgramData\Miniconda3\envs\imageai\lib\site-packages\keras\initializers\__init__.py", line 124, in <module>
    populate_deserializable_objects()
  File "C:\ProgramData\Miniconda3\envs\imageai\lib\site-packages\keras\initializers\__init__.py", line 49, in populate_deserializable_objects
    LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

Can anyone make sense of this?

Doing a search for this error (on the bottom line), I read on StackOverflow (here) that "From Tensorflow 2.x onward, keras is no longer maintained and it became a part of Tensorflow." (And something similar is here.) Is this related to my issue? And if so, how would I fix it?

Thank you.

Chevelle102 commented 3 years ago

try to install keras==2.5.0rc0