How to fix module 'tensorflow' has no attribute 'get_default_session'

一笑奈何 提交于 2020-01-24 00:43:26

问题


Help solve that problem please I use ImageAI to detect cars , but it didn't works , i'm newbee in this , sorry

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, objects_path = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image3.jpg"), output_image_path=os.path.join(execution_path , "image3new.jpg"), minimum_percentage_probability=30,  extract_detected_objects=True)


for eachObject, eachObjectPath in zip(detections, objects_path):
    print(eachObject["name"] , " : " , eachObject["percentage_probability"], " : ", eachObject["box_points"] )
    print("Object's image saved in " + eachObjectPath)
    print("--------------------------------")

Using TensorFlow backend.

Traceback (most recent call last):
File "/home/maxim/PycharmProjects/ImageAI/venv/image.py", line 7, in <module>
    detector = ObjectDetection()
File "/home/maxim/.virtualenvs/ImageAI/lib/python3.5/site-packages/imageai/Detection/__init__.py", line 88, in __init__
    self.sess = K.get_session()
  File "/home/maxim/.virtualenvs/ImageAI/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 174, in get_session
    default_session = tf.get_default_session()
AttributeError: module 'tensorflow' has no attribute 'get_default_session'

Process finished with exit code 1

来源:https://stackoverflow.com/questions/56961839/how-to-fix-module-tensorflow-has-no-attribute-get-default-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!