【问题标题】:How to fix module 'tensorflow' has no attribute 'get_default_session'如何修复模块“tensorflow”没有属性“get_default_session”
【发布时间】:2019-07-10 00:04:57
【问题描述】:

请帮助解决这个问题 我使用 ImageAI 来检测汽车,但它不起作用,我是这方面的新手,对不起

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

使用 TensorFlow 后端。

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

【问题讨论】:

  • 请更好地组织您的问题。代码的结构和错误都不清楚
  • 有组织的。抱歉,我是该平台的第一天。 :c
  • 你使用的是 tensorflow 2.0 吗?
  • 是的,我正在安装 2.0,因为在 1.14 上有很多错误,我建议安装 2.0

标签: python tensorflow neural-network


【解决方案1】:

https://github.com/OlafenwaMoses/ImageAI/issues/563

没错,它 (ImageAI) 与 Collecting keras==2.1.6 一起使用,在 colob 上检查过,谢谢

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-05-25
  • 2019-08-25
  • 2020-09-03
  • 2020-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-02
相关资源
最近更新 更多