【问题标题】:label_map_util.load_labelmap Error: module 'tensorflow' has no attribute 'gfile'label_map_util.load_labelmap 错误:模块“tensorflow”没有属性“gfile”
【发布时间】:2020-04-29 14:53:51
【问题描述】:
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)

AttributeError Traceback(最近调用 最后)在 ----> 1 label_map = label_map_util.load_labelmap(PATH_TO_LABELS) 2 个类别 = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True) 3 category_index = label_map_util.create_category_index(categories)

c:\ML\od\models\research\object_detection\utils\label_map_util.py 在 load_labelmap(路径) 第136章 第137章 --> 138 with tf.gfile.GFile(path, 'r') as fid: 第139章 140 label_map = string_int_label_map_pb2.StringIntLabelMap()

AttributeError: 模块 'tensorflow' 没有属性 'gfile'

我知道问题的原因,它是由于 (import tensorflow.compat.v1 as tf) 在 2.0.0 中不兼容造成的。我在自定义代码中使用 import tensorflow.compat.v1 as tf 解决了这个问题,但问题来自 model/research/object_detection/utils 内部的 label_map_util。

我是否必须将版本从 2.0.* 降级到 1.* 或者我缺少任何解决方案。

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    是的,必须降级到版本 1.*。 Glfile 在 2.0 中被移除。

    【讨论】:

      猜你喜欢
      • 2019-08-30
      • 1970-01-01
      • 2021-06-16
      • 1970-01-01
      • 2020-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多