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.5k stars 2.18k forks source link

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu' #77

Closed varunajmera0 closed 5 years ago

varunajmera0 commented 5 years ago

Using TensorFlow backend. <class 'imageai.Detection.ObjectDetection'> Traceback (most recent call last): File "imaged.py", line 13, in detector.loadModel() File "/usr/local/lib/python3.7/site-packages/imageai/Detection/init.py", line 189, in loadModel model = yolo_main(Input(shape=(None, None, 3)), len(self.__yolo_anchors) // 3, len(self.numbers_to_names)) File "/usr/local/lib/python3.7/site-packages/imageai/Detection/YOLOv3/models.py", line 60, in yolo_main darknet_network = Model(input, darknet(input)) File "/usr/local/lib/python3.7/site-packages/imageai/Detection/YOLOv3/models.py", line 33, in darknet network = NetworkConv2D_BN_Leaky(input=input, channels=32, kernel_size=(3,3)) File "/usr/local/lib/python3.7/site-packages/imageai/Detection/YOLOv3/models.py", line 18, in NetworkConv2D_BN_Leaky network = LeakyReLU(alpha=0.1)(network) File "/usr/local/lib/python3.7/site-packages/keras/engine/base_layer.py", line 457, in call output = self.call(inputs, **kwargs) File "/usr/local/lib/python3.7/site-packages/keras/layers/advanced_activations.py", line 46, in call return K.relu(inputs, alpha=self.alpha) File "/usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 3116, in relu x = tf.nn.leaky_relu(x, alpha) AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'

RohitJacob commented 5 years ago

I've got this problem too. Is there a solution to this? @OlafenwaMoses @johnolafenwa

OlafenwaMoses commented 5 years ago

There is a fix to it, as the error seems to arise from newer versions of Keras after 2.1.2 Uninstall your current Keras installation and install Keras 2.1.2

See link below for reference

https://github.com/keras-team/keras/issues/9349

varunajmera0 commented 5 years ago

screen shot 2018-09-30 at 5 28 39 pm