【问题标题】:Why Tensorflow has no attribute 'gfile' even after I changed the file?为什么即使我更改了文件,Tensorflow 也没有属性“gfile”?
【发布时间】:2021-06-17 16:01:20
【问题描述】:

我得到错误AttributeError: module 'tensorflow' has no attribute 'gfile' 所以我在网上发现现在我们必须将tf.gfile 更改为tf.io.gfile
所以我在C:\Anaconda\lib\site-packages\object_detection\utils\config_util.py 中更改了它,但它仍然不适合我。

错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-14-efc7822bb0d7> in <module>
----> 1 config = config_util.get_configs_from_pipeline_file(CONFIG_PATH)

C:\Anaconda\lib\site-packages\object_detection\utils\config_util.py in get_configs_from_pipeline_file(pipeline_config_path, config_override)
     94   """
     95   pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
---> 96   with tf.io.gfile.GFile(pipeline_config_path, "r") as f:
     97     proto_str = f.read()
     98     text_format.Merge(proto_str, pipeline_config)

AttributeError: module 'tensorflow' has no attribute 'gfile'

谁能帮帮我?
我是新手????

【问题讨论】:

标签: python tensorflow object-detection


【解决方案1】:

import tensorflow as tf 替换为import tensorflow.compat.v1 as tf 并检查它是否有效

【讨论】:

  • 如果可以的话,请分享你用过的笔记本的链接
  • 您使用的 TensorFlow 版本是什么?
  • 是2.4.1,我刚用!pip install tensorfow,我觉得是最新的
  • this post 回答你的问题了吗?
【解决方案2】:

降级到 tensorflow 2.3.0 由

pip install tensorflow==2.3.0

你可以从https://www.tensorflow.org/install/source_windows#install_the_package看到不同的版本

【讨论】:

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