为了账号安全,请及时绑定邮箱和手机立即绑定

TensorFlow2.0.0 Alpha-模块'tensorflow'没有属性'gfile'

TensorFlow2.0.0 Alpha-模块'tensorflow'没有属性'gfile'

MM们 2022-06-14 17:45:24
使用 tensorflow==2.0.0-alpha0 在 Windows10 上使用 Python 3.7.0 运行以下 Python 代码时出现上述错误:import numpy as npimport osimport six.moves.urllib as urllibimport tarfileimport tensorflow as tfimport zipfilefrom collections import defaultdictfrom io import StringIOfrom matplotlib import pyplot as pltfrom PIL import Imagefrom object_detection.utils import ops as utils_ops%matplotlib inlinefrom object_detection.utils import label_map_utilfrom object_detection.utils import visualization_utils as vis_utilPATH_TO_LABELS = os.path.join('C:\\Users\\User\\models\\research\\object_detection\\data', 'mscoco_label_map.pbtxt')PATH_TO_FROZEN_GRAPH = os.path.join('C:\\Users\\User\\models\\research\\object_detection\\ssd_mobilenet_v1_coco_2017_11_17', 'frozen_inference_graph.pb')PATH_TO_CKPT = PATH_TO_FROZEN_GRAPHwith detection_graph.as_default():    od_graph_def = tf.compat.v1.GraphDef()    with tf.compat.v2.io.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid:        serialized_graph = fid.read()        od_graph_def.ParseFromString(serialized_graph)        tf.import_graph_def(od_graph_def, name='')NUM_CLASSES=90label_map = label_map_util.load_labelmap(PATH_TO_LABELS)有什么建议么?好心,吉拉德
查看完整描述

2 回答

?
Helenr

TA贡献1780条经验 获得超3个赞

gfile移至tf.ioin tensorflow-2。所以你需要导入tf.io而不是仅仅导入tensorflow as tf



查看完整回答
反对 回复 2022-06-14
?
千万里不及你

TA贡献1784条经验 获得超9个赞

在 tf2.0 中,gfile 包已移至 tf.io。所以你可以使用 tf.io.gfile



查看完整回答
反对 回复 2022-06-14
  • 2 回答
  • 0 关注
  • 145 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信