微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用ImageAi,TensorFlow,OpenCV时出错

如何解决使用ImageAi,TensorFlow,OpenCV时出错

我通过Tutorial用Python尝试ImageAI。教程录制于2019年。现在此代码不起作用。

代码

from imageai.Detection import ObjectDetection
import os
import tensorflow.compat.v1 as tf

tf.disable_v2_behavior()
exec_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(
    exec_path,"resnet.h5")
)
detector.loadModel()

list = detector.detectObjectsFromImage(
    input_image=os.path.join(exec_path,"objects.jpg"),output_image_path=os.path.join(exec_path,"new_objects.jpg"),minimum_percentage_probability=90,display_percentage_probability=True,display_object_name=False
)

Run(PyCharm)的输出

AttributeError: module 'tensorflow' has no attribute 'get_default_session'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。