无法将检查点模型转换为Tensorflow图原型

时间:2018-09-03 05:57:10

标签: python tensorflow

系统信息:

  • Windows 10
  • Tensorflow版本:1.10.0(通过pip安装)
  • 我的系统上没有GPU。

我用1个类创建了约100张图像的数据集,并运行legacy / train.py脚本进行了培训。我得到了以下检查点文件:

model.ckpt-649.data-00000-of-00001
model.ckpt-649.index
model.ckpt-649.meta

但是,当我运行export_inference_graph.py文件时,出现以下错误。

  

python。\ object_detection \ export_inference_graph.py --input_type   image_tensor --pipeline_config_path   。\ object_detection \ training \ ssd_mobilenet_v1_pets.config   --trained_checkpoint_prefix。\ object_detection \ training \ model.ckpt-649.index --output_directory   。\ object_detection \ trained-interference-graphs

我最终希望使用.pb文件通过tensorflow提供的代码来评估模型。

日志:

Traceback (most recent call last):
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1278, in _do_call
    return fn(*args)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1263, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1350, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "BoxPredictor_0/BoxEncodingPredictor/biases" not found in checkpoint fil
es .\object_detection\training\model.ckpt-649.index
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT
_FLOAT, DT_INT64], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2
/shape_and_slices)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\training\saver.py", line 1725, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 877, in run
    run_metadata_ptr)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run
    feed_dict_tensor, options, run_metadata)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1272, in _do_run
    run_metadata)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\client\session.py", line 1291, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.NotFoundError: Tensor name "BoxPredictor_0/BoxEncodingPredictor/biases" not found in checkpoint fil
es .\object_detection\training\model.ckpt-649.index
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT
_FLOAT, DT_INT64], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2
/shape_and_slices)]]

Caused by op 'save/RestoreV2', defined at:
  File ".\object_detection\export_inference_graph.py", line 153, in <module>
    tf.app.run()
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File ".\object_detection\export_inference_graph.py", line 149, in main
    write_inference_graph=FLAGS.write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 405, in export_inference_graph
    write_inference_graph=write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 334, in _export_inference_graph
    trained_checkpoint_prefix=checkpoint_to_use)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 241, in write_graph_and_checkpoint
    tf.import_graph_def(inference_graph_def, name='')
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\importer.py", line 442, in import_graph_def
    _ProcessNewOps(graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\importer.py", line 234, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False):  # pylint: disable=protected-access
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3289, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3289, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3180, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in __init__
    self._traceback = tf_stack.extract_stack()

NotFoundError (see above for traceback): Tensor name "BoxPredictor_0/BoxEncodingPredictor/biases" not found in checkpoint files .\object_de
tection\training\model.ckpt-649.index
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT
_FLOAT, DT_INT64], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2
/shape_and_slices)]]


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\training\saver.py", line 1737, in restore
    checkpointable.OBJECT_GRAPH_PROTO_KEY)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 348, in get_tensor
    status)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\errors_impl.py", line 519, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: _CHECKPOINTABLE_OBJECT_GRAPH not found in checkpoint file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\object_detection\export_inference_graph.py", line 153, in <module>
    tf.app.run()
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File ".\object_detection\export_inference_graph.py", line 149, in main
    write_inference_graph=FLAGS.write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 405, in export_inference_graph
    write_inference_graph=write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 334, in _export_inference_graph
    trained_checkpoint_prefix=checkpoint_to_use)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 245, in write_graph_and_checkpoint
    saver.restore(sess, trained_checkpoint_prefix)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\training\saver.py", line 1743, in restore
    err, "a Variable name or other graph key that is missing")
tensorflow.python.framework.errors_impl.NotFoundError: Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Origin
al error:

Tensor name "BoxPredictor_0/BoxEncodingPredictor/biases" not found in checkpoint files .\object_detection\training\model.ckpt-649.index
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT
_FLOAT, DT_INT64], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2
/shape_and_slices)]]

Caused by op 'save/RestoreV2', defined at:
  File ".\object_detection\export_inference_graph.py", line 153, in <module>
    tf.app.run()
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File ".\object_detection\export_inference_graph.py", line 149, in main
    write_inference_graph=FLAGS.write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 405, in export_inference_graph
    write_inference_graph=write_inference_graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 334, in _export_inference_graph
    trained_checkpoint_prefix=checkpoint_to_use)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\models\research\object_detection\exporter.py", line 241, in write_graph_and_checkpoint
    tf.import_graph_def(inference_graph_def, name='')
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func
    return func(*args, **kwargs)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\importer.py", line 442, in import_graph_def
    _ProcessNewOps(graph)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\importer.py", line 234, in _ProcessNewOps
    for new_op in graph._add_new_tf_operations(compute_devices=False):  # pylint: disable=protected-access
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3289, in _add_new_tf_operations
    for c_op in c_api_util.new_tf_operations(self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3289, in <listcomp>
    for c_op in c_api_util.new_tf_operations(self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 3180, in _create_op_from_tf_operation
    ret = Operation(c_op, self)
  File "C:\Anaconda3\Lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in __init__
    self._traceback = tf_stack.extract_stack()

NotFoundError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a Variable name or other graph key that is missing from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:

Tensor name "BoxPredictor_0/BoxEncodingPredictor/biases" not found in checkpoint files .\object_detection\training\model.ckpt-649.index
         [[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT
_FLOAT, DT_INT64], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2
/shape_and_slices)]]

0 个答案:

没有答案