如何修复模块“tensorflow"没有属性“get_default_session" [英] How to fix module 'tensorflow' has no attribute 'get_default_session'
本文介绍了如何修复模块“tensorflow"没有属性“get_default_session"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请帮忙解决这个问题我使用 ImageAI 检测汽车,但它不起作用,我是新手,抱歉
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("--------------------------------")
使用 TensorFlow 后端.
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://github.com/OlafenwaMoses/ImageAI/issues/563
你说得对 (ImageAI) 与收集 keras==2.1.6 一起工作,在 colob 上检查,谢谢
You're right it (ImageAI) works with Collecting keras==2.1.6, checked on colob, Thanks
这篇关于如何修复模块“tensorflow"没有属性“get_default_session"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文