Tensorflow Object Detection API ValueError: No variables to save解决方案

问题阐述:
在使用Tensorflow Object Detection API进行目标检测时,使用有些网络的config文件进行transfer learning的训练会出现报错:ValueError: No variables to save

Traceback (most recent call last):
  File "train.py", line 184, in <module>
    tf.app.run()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/platform/app.py", line 126, in run
    _sys.exit(main(argv))
  File "train.py", line 180, in main
    graph_hook_fn=graph_rewriter_fn)
  File "/content/models/research/object_detection/trainer.py", line 381, in train
    init_saver = tf.train.Saver(available_var_map)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1338, in __init__
    self.build()
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1347, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/training/saver.py", line 1372, in _build
    raise ValueError("No variables to save")
ValueError: No variables to save

原因分析:
没有调用到预训练的模型,需要修改config文件。

  fine_tune_checkpoint: "/path_to_model/model.ckpt"
  from_detection_checkpoint: true
  load_all_detection_checkpoint_vars: true
  fine_tune_checkpoint_type:  "detection"

即在fine_tune_checkpoint后面加入上述3句话。

猜你喜欢

转载自blog.csdn.net/gaoqing_dream163/article/details/114371396