在运行使用tf.gfile.GFile
和tf.io.gfile.GFile
的代码后,我仍然遇到这个错误。你能帮我吗?
Windows 10
tensorflow GPU版本: 2.1.0
代码
`import tensorflow.compat.v1 as tfdetection_graph = tf.Graph()with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') `
以及这段代码:
`
import tensorflow as tfdetection_graph = tf.Graph()with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.io.gfile.GFile(PATH_TO_CKPT, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='')
`
回答:
我通过卸载TensorFlow 2.xx解决了这个问题,请安装1x TensorFlow的最后一个版本,即1.15
如果你使用Google Colab,请使用命令安装tensorflow 1.15: !pip3 install tensorflow==1.15
此外,你可以在笔记本的顶部使用%tensorflow_version 1.x
来确保只使用1x版本
从这里复制这两段代码:!pip3 install tensorflow==1.15
%tensorflow_version 1.x