Не работает программа Tensorflow python

Вот код:


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"] )

Когда запускаю выдает:

Microsoft Windows [Version 10.0.18362.836]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\andre>cd Desktop/ImageDetection

C:\Users\andre\Desktop\ImageDetection>python FirstDetection.py
Using TensorFlow backend.
2020-06-09 15:17:02.874475: 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-06-09 15:17:02.881211: 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 "FirstDetection.py", line 7, in <module>
    detector = ObjectDetection()
  File "C:\Users\andre\AppData\Local\Programs\Python\Python38\lib\site-packages\imageai\Detection\__init__.py", line 75, in __init__
    self.sess = K.get_session()
  File "C:\Users\andre\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\tensorflow_backend.py", line 378, in get_session
    raise RuntimeError(
RuntimeError: `get_session` is not available when using TensorFlow 2.0.

C:\Users\andre\Desktop\ImageDetection>

Что делать?


Ответы (1 шт):

Автор решения: Андрей Козак

Попробуйте дописать в начало tf.disable_v2_behavior() Это должно избавить от ошибки: RuntimeError: 'get_session' is not available when using TensorFlow 2.0

→ Ссылка