簡體   English   中英

TensorFlow2.0.0 Alpha-模塊'tensorflow'沒有屬性'gfile'

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

在 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)

有什么建議么? 好心,吉拉德

gfile移至tf.io tensorflow-2中的 tf.io 。 所以你需要導入tf.io而不是僅僅導入tensorflow as tf

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM