Search code examples
pythonkerasdeep-learningcomputer-visionimageai

object detection using imageAI


I am working on a plant leaf detection model using imageAI library. when I create an instance of the model the following error occurs. I can not understand the error. this is my code:

from imageai.Detection import ObjectDetection
detector = ObjectDetection()

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-3bc804fbfef2> in <module>()
      1 from imageai.Detection import ObjectDetection
----> 2 detector = ObjectDetection()

/usr/local/lib/python3.6/dist-packages/imageai/Detection/__init__.py in __init__(self)
     86         self.__yolo_model_image_size = (416, 416)
     87         self.__yolo_boxes, self.__yolo_scores, self.__yolo_classes = "", "", ""
---> 88         self.sess = K.get_session()
     89 
     90         # Unique instance variables for TinyYOLOv3.

AttributeError: module 'keras.backend' has no attribute 'get_session'

Solution

  • you have to use older version of keras and tensorflow.

    try this

    pip3 install tensorflow==1.13.1

    pip3 install keras==2.2.4

    or you can install tensorflow 1.14 or 1.15.1