Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TensorFlow2.0.0 Alpha-模块';tensorflow';没有属性';gfile';_Python_Tensorflow - Fatal编程技术网

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

Python TensorFlow2.0.0 Alpha-模块';tensorflow';没有属性';gfile';,python,tensorflow,Python,Tensorflow,我在Windows10上使用Python 3.7.0在tensorflow==2.0.0-alpha0运行以下Python代码时出现上述错误: import numpy as np import os import six.moves.urllib as urllib import tarfile import tensorflow as tf import zipfile from collections import defaultdict from io import StringIO f

我在Windows10上使用Python 3.7.0在tensorflow==2.0.0-alpha0运行以下Python代码时出现上述错误:

import numpy as np
import os
import six.moves.urllib as urllib
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from object_detection.utils import ops as utils_ops
%matplotlib inline

from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util

PATH_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_GRAPH

with 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=90
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
有什么建议吗? 好心的
Gilad

gfile
tensorflow-2
中移动到
tf.io

因此,您需要导入
tf.io
,而不是在tf2.0中将
tensorflow作为tf
导入,gfile包已移动到tf.io中。所以你可以使用tf.io.gfile

可能的