如何在Tensorflow对象检测API

问题描述

我正在尝试使用TensorFlow zoo hear中的EfficientDet D3模型使用TensorFlow对象检测API进行对象检测。我在第2节预训练检查点下找到了预训练检查点hear的文件夹。

我需要在.config文件中指定检查点的路径进行训练。但是我无法从模型中找到.ckpt文件,也无法从上面下载的经过预先训练的检查点文件夹中找到文件。

我发现洋红色也有类似的问题hear。但这对我不起作用。如果有人知道如何在Tensorflow 2中从model.ckpt生成model.ckpt-data-00000-of-000001,model.ckpt.index,model.ckpt.meta文件,请告诉我它可能可以解决我的问题

我正在使用Google colab的TensorFlow 2

编辑1:我从TensorFlow model zoo下载了模型。它具有波纹管结构。

在路径/content/models/research/object_detection/EfficientDet_D3/ # this is model dir

efficientdet_d3_coco17_tpu-32/
efficientdet_d3_coco17_tpu-32/checkpoint/
efficientdet_d3_coco17_tpu-32/checkpoint/ckpt-0.data-00000-of-00001
efficientdet_d3_coco17_tpu-32/checkpoint/checkpoint
efficientdet_d3_coco17_tpu-32/checkpoint/ckpt-0.index
efficientdet_d3_coco17_tpu-32/pipeline.config
efficientdet_d3_coco17_tpu-32/saved_model/
efficientdet_d3_coco17_tpu-32/saved_model/saved_model.pb
efficientdet_d3_coco17_tpu-32/saved_model/assets/
efficientdet_d3_coco17_tpu-32/saved_model/variables/
efficientdet_d3_coco17_tpu-32/saved_model/variables/variables.data-00000-of-00001
efficientdet_d3_coco17_tpu-32/saved_model/variables/variables.index

我还使用this中EfficientDet自述文件中的github链接下载了检查点。它的结构看起来像波纹管。

在路径/content/models/research/object_detection/efficientdet-d3/ # this is checkpoint dir

efficientdet-d3/
efficientdet-d3/model.meta
efficientdet-d3/d3_coco_val_softnms.txt
efficientdet-d3/d3_coco_test-dev2017_softnms.txt
efficientdet-d3/model.index
efficientdet-d3/detections_test-dev2017_d3_results.zip
efficientdet-d3/checkpoint
efficientdet-d3/model.data-00000-of-00001

我在下面的.ckpt中指定了到pipeline.config的路径。

fine_tune_checkpoint: "/content/models/research/object_detection/efficientdet-d3/model.ckpt"

但是当我遇到错误提示时,这似乎是不正确的。

Traceback (most recent call last):
  File "model_main_tf2.py",line 113,in <module>
    tf.compat.v1.app.run()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py",line 40,in run
    _run(main=main,argv=argv,flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py",line 300,in run
    _run_main(main,args)
  File "/usr/local/lib/python3.6/dist-packages/absl/app.py",line 251,in _run_main
    sys.exit(main(argv))
  File "model_main_tf2.py",line 110,in main
    record_summaries=FLAGS.record_summaries)
  File "/root/.local/lib/python3.6/site-packages/object_detection-0.1-py3.6.egg/object_detection/model_lib_v2.py",line 569,in train_loop
    unpad_groundtruth_tensors)
  File "/root/.local/lib/python3.6/site-packages/object_detection-0.1-py3.6.egg/object_detection/model_lib_v2.py",line 345,in load_fine_tune_checkpoint
    if not is_object_based_checkpoint(checkpoint_path):
  File "/root/.local/lib/python3.6/site-packages/object_detection-0.1-py3.6.egg/object_detection/model_lib_v2.py",line 308,in is_object_based_checkpoint
    var_names = [var[0] for var in tf.train.list_variables(checkpoint_path)]
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/checkpoint_utils.py",line 98,in list_variables
    reader = load_checkpoint(ckpt_dir_or_file)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/checkpoint_utils.py",line 67,in load_checkpoint
    return py_checkpoint_reader.NewCheckpointReader(filename)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/py_checkpoint_reader.py",line 99,in NewCheckpointReader
    error_translator(e)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/py_checkpoint_reader.py",line 35,in error_translator
    raise errors_impl.NotFoundError(None,None,error_message)
tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for /content/models/research/object_detection/efficientdet-d3/model.ckpt

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)