简体   繁体   English

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

[英]TensorFlow2.0.0 Alpha- module 'tensorflow' has no attribute 'gfile'

I got the above error when running the followed Python code on Windows10 with Python 3.7.0 with tensorflow==2.0.0-alpha0:在 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)

Any suggestions?有什么建议么? Kindly, Gilad好心,吉拉德

gfile is moved to tf.io in tensorflow-2 . gfile移至tf.io tensorflow-2中的 tf.io 。 so you need to import tf.io instead of just importing tensorflow as tf所以你需要导入tf.io而不是仅仅导入tensorflow as tf

In tf2.0, the gfile package has been moved into tf.io.在 tf2.0 中,gfile package 已移至 tf.io。 so u can use tf.io.gfile所以你可以使用 tf.io.gfile

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError:模块'tensorflow'没有属性'gfile'Tensorflow 2.8.2 - AttributeError: module 'tensorflow' has no attribute 'gfile' Tensorflow 2.8.2 AttributeError:即使在第 131 行将 tf.gfile.* 更改为 tf.io.gfile.*,模块“tensorflow”也没有属性“gfile” - AttributeError: module 'tensorflow' has no attribute 'gfile' even when changed tf.gfile.* to tf.io.gfile.* in line 131 在 TensorFlow2.0.0 中创建自定义激活 - Creating custom activations in TensorFlow2.0.0 label_map_util.load_labelmap 错误:模块“tensorflow”没有属性“gfile” - label_map_util.load_labelmap Error: module 'tensorflow' has no attribute 'gfile' 仍然得到 AttributeError: module 'tensorflow' has no attribute 'gfile' 在尝试了每件事来解决这个问题之后 - Still getting AttributeError: module 'tensorflow' has no attribute 'gfile' after trying every thing to solve that 为什么 Tensorflow 即使在我更改文件后也没有属性“gfile”? - Why Tensorflow has no attribute 'gfile' even after I changed the file? Tensorflow==2.0.0a0 - AttributeError: 模块“tensorflow”没有属性“global_variables_initializer” - Tensorflow==2.0.0a0 - AttributeError: module 'tensorflow' has no attribute 'global_variables_initializer' Tensorflow:模块'tensorflow'没有属性'constant' - Tensorflow: module 'tensorflow' has no attribute 'constant' 模块 'tensorflow' 没有属性 'random' - module 'tensorflow' has no attribute 'random' 模块“tensorflow”没有属性“constant” - module 'tensorflow' has no attribute 'constant'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM