Luis Vivas
Luis Vivas

Reputation: 145

YOLOv3 ModuleNotFoundError: No module named 'tensorflow.python.keras.engine.base_layer_v1'

I need to train a model using YOLO. I am using the Kaggle kernel and I am training custom images.

When I execute the train module, I get this error.

ModuleNotFoundError: No module named 'tensorflow.python.keras.engine.base_layer_v1'

preinstalled is Tensorflow 2.+. I read somewhere that Yolov3 does not work with TensorFlow 2.+ so I installed Tensor 1.14.

I also tried using ImageAi and got exactly the same error.

Does anyone understand this basekayer_v1? Is it the tensorflow version that give the error?

Thanks

Upvotes: 0

Views: 3001

Answers (1)

Luis Vivas
Luis Vivas

Reputation: 145

I found the solution

Well, it looks that I am doing things wrong or more difficult since no one encounter this error. I found the solution.

from keras.preprocessing import image
from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
from keras import backend as K

to:

from tensorflow.keras.preprocessing import image
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Dense, GlobalAveragePooling2D
from tensorflow.keras import backend as K

If you have the same problem. YOLO files are outdated. They are said that they are not compatible with Tensorflow 1.14 but for me it worked. I needed to fork the git and edit the model.py. As shown above the important thing is add tensorflow.keras

I also needed to edit Change K.controlflowops.whileloop to tf.whileloop in the code or will give you an error.

I used Kaggle kernel. Using Tensorflow 2.0.2

It took me 4 days to solve this, now it is finally training. I hope it helps.

Upvotes: 1

Related Questions