Я пытался запустить этот скрипт с Python 3.7 и PyCharm 2019 CE, уже установил все необходимые библиотеки.
https://towardsdatascience.com/object-detection-with-10-lines-of-code-d6cb4d86f606
from imageai.Detection import ObjectDetection
import os
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))
for eachObject in detections:
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )
И затем я получил это сообщение об ошибке:
C:\Program Files\Python37\python.exe" "D:/Kuliah/SMT 5/AI/TR/FirstDetection.py"
Using TensorFlow backend.
2020-03-31 00:40:15.115871: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-03-31 00:40:15.116113: 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 "D:/Kuliah/SMT 5/AI/TR/FirstDetection.py", line 6, in <module>
detector = ObjectDetection()
File "C:\Program Files\Python37\lib\site-packages\imageai\Detection\__init__.py", line 88, in __init__
self.sess = K.get_session()
File "C:\Program Files\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 379, in get_session
'`get_session` is not available '
RuntimeError: `get_session` is not available when using TensorFlow 2.0.
Process finished with exit code 1