使用 imageAI 进行物体检测

object detection using imageAI

我正在使用 imageAI 库开发植物叶子检测模型。当我创建模型的实例时,发生以下错误。我无法理解错误。 这是我的代码:

from imageai.Detection import ObjectDetection
detector = ObjectDetection()

错误:

---------------------------------------------------------------------------
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'

你必须使用旧版本的 keras 和 tensorflow。

试试这个

pip3 install tensorflow==1.13.1

pip3 install keras==2.2.4

或者您可以安装 tensorflow 1.14 或 1.15.1

关注这个版本..

Package                 Version
----------------------- ---------
absl-py                 0.15.0
astunparse              1.6.3
cached-property         1.5.2
cachetools              4.2.4
certifi                 2021.10.8
charset-normalizer      2.0.7
cycler                  0.10.0
flatbuffers             1.12
gast                    0.3.3
google-auth             2.3.0
google-auth-oauthlib    0.4.6
google-pasta            0.2.0
grpcio                  1.32.0
h5py                    2.10.0
idna                    3.3
imageai                 2.1.6
importlib-metadata      4.8.1
Keras                   2.4.3
Keras-Preprocessing     1.1.2
keras-resnet            0.2.0
kiwisolver              1.3.2
Markdown                3.3.4
matplotlib              3.3.2
numpy                   1.19.3
oauthlib                3.1.1
opencv-python           4.5.3.56
opt-einsum              3.3.0
Pillow                  7.0.0
pip                     21.2.4
protobuf                3.19.0rc1
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pyparsing               2.4.7
python-dateutil         2.8.2
PyYAML                  6.0
requests                2.26.0
requests-oauthlib       1.3.0
rsa                     4.7.2
scipy                   1.4.1
setuptools              58.0.4
six                     1.15.0
tensorboard             2.7.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow              2.4.0
tensorflow-estimator    2.4.0
termcolor               1.1.0
typing-extensions       3.7.4.3
urllib3                 1.26.7
Werkzeug                2.0.2
wheel                   0.37.0
wincertstore            0.2
wrapt                   1.12.1
zipp                    3.6.0