Search code examples
tensorflowpython-3.6google-colaboratoryobject-detection-api

Tensorflow Object Detection API ValueError: No variables to save


I'm trying to train a custom object detection model using tensorflow object detection api. For the training purposes I used pickled image data set for training and as model I used ssd_mobilenet_v1_coco. When I started the training it gave me this error.

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

Full error code can find here...

[https://gist.github.com/mpgovinda/1f59f7de7873f6ec4c4426b79dc6827a][1]

How do I resolve this?


Solution

  • Tested Solution

    Add fine_tune_checkpoint_type: "detection" to train_config: { ... } section in your *.config file.

    Sample

    train_config: {
      ...
      fine_tune_checkpoint: "./pre_trained_model/model.ckpt"
      fine_tune_checkpoint_type:  "detection"
      ...
    }
    

    Tested on ssd_mobilenet_v1_quantized_300x300_coco14_sync model.