【问题标题】:tf-1.5 or tf-2.1 when running object detection training运行对象检测训练时的 tf-1.5 或 tf-2.1
【发布时间】:2020-05-06 01:53:57
【问题描述】:

当我尝试运行时:

来自 tensorflow/models/research/ 目录

PIPELINE_CONFIG_PATH=/home/paul/objdetect/models/research/object_detection/samples/configs/ssdlite_mobilenet_v3_small_320x320_kitti.config
MODEL_DIR=/home/paul/objdetect/models/research/object_detection/samples/sample_model_ckpt/
NUM_TRAIN_STEPS=5000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1
python object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \
    --alsologtostderr

如果我使用 tensorflow-gpu==1.5.0 环境,我得到以下错误:

    from nets import inception_resnet_v2
  File "/home/paul/objdetect/models/research/slim/nets/inception_resnet_v2.py", line 375, in <module>
    batch_norm_updates_collections=tf.compat.v1.GraphKeys.UPDATE_OPS,
AttributeError: 'module' object has no attribute 'v1'

然后我切换到tensorflow-gpu==2.1.0环境,再次运行,出现如下错误:

    from object_detection import eval_util
  File "/home/paul/objdetect/models/research/object_detection/eval_util.py", line 40, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

那么有没有办法运行它呢?我需要修复什么才能让它在 tf-1.5 或 tf-2.1 中运行?

有人可以帮忙吗?非常感谢您。

此致,

-保罗

【问题讨论】:

    标签: tensorflow object-detection-api


    【解决方案1】:

    tf.contrib 在 tf2.x 中已被弃用。同样,在 1.14.x 和 1.15.x 中引入了 tf.compat,用于解决 tf 1.x 和 tf2.x 之间的兼容性问题。尝试安装tensorflow 1.15.x版本并运行

    【讨论】:

    • 谢谢阿杰。我一直对 1.5 > 1.15 感到困惑(这让我觉得我的版本比 1.15 更高;(现在回想一下,安装 1.15.0 并运行。
    • 如果我想拥有 tf2.0 怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-11
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 2018-10-16
    相关资源
    最近更新 更多