I am trying to do object detection using TensorFlow Object detection API using ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8 model from TensorFlow model zoo. I'm able to detect single test images using the ckpt file (saved as ckpt-17.data-00000-of-00001)
I need to convert this ckpt to some saved model file(.pb/.h5) to use in a simple flask webapp.
I'm finding it difficult to convert the ckpt file to .pb using the below code
print("""python {}/research/object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path={}/{}/pipeline.config \
--trained /content/RealTimeObjectDetectionStages/Tensorflow/workspace/models/my_ssd_mobnet/ckpt-17.index \
--output_directory /content/RealTimeObjectDetectionStages/Tensorflow/workspace/models""".format(APIMODEL_PATH, MODEL_PATH,CUSTOM_MODEL_NAME,MODEL_PATH,CUSTOM_MODEL_NAME))
!python /content/RealTimeObjectDetectionStages/Tensorflow/models/research/object_detection/export_inference_graph.py --input_type image_tensor --pipeline_config_path=/content/RealTimeObjectDetectionStages/Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config --trained /content/RealTimeObjectDetectionStages/Tensorflow/workspace/models/my_ssd_mobnet/ckpt-17.ckpt --output_directory /content/RealTimeObjectDetectionStages/Tensorflow/workspace/models
And getting the following error when I'm trying to convert to .pb
2021-03-12 11:25:57.212865: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0 Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/absl/flags/_flagvalues.py", line 541, in _assert_validators validator.verify(self) File "/usr/local/lib/python3.7/dist-packages/absl/flags/_validators.py", line 82, in verify raise _exceptions.ValidationError(self.message) absl.flags._exceptions.ValidationError: Flag --trained_checkpoint_prefix must have a value other than None. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/content/RealTimeObjectDetectionStages/Tensorflow/models/research/object_detection/export_inference_graph.py", line 206, in tf.app.run() File "/usr/local/lib/python3.7/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.7/dist-packages/absl/app.py", line 294, in run flags_parser, File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 363, in _run_init flags_parser=flags_parser, File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 213, in _register_and_parse_flags_with_usage args_to_main = flags_parser(original_argv) File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/platform/app.py", line 31, in _parse_flags_tolerate_undef return flags.FLAGS(_sys.argv if argv is None else argv, known_only=True) File "/usr/local/lib/python3.7/dist-packages/tensorflow/python/platform/flags.py", line 113, in __call__ return self.__dict__['__wrapped'].__call__(*args, **kwargs) File "/usr/local/lib/python3.7/dist-packages/absl/flags/_flagvalues.py", line 649, in __call__ self.validate_all_flags() File "/usr/local/lib/python3.7/dist-packages/absl/flags/_flagvalues.py", line 523, in validate_all_flags self._assert_validators(all_validators) File "/usr/local/lib/python3.7/dist-packages/absl/flags/_flagvalues.py", line 544, in _assert_validators raise _exceptions.IllegalFlagValueError('%s: %s' % (message, str(e))) absl.flags._exceptions.IllegalFlagValueError: flag --trained_checkpoint_prefix=None: Flag --trained_checkpoint_prefix must have a value other than None.
How to save the checkpoints for deployment?
I am using TensorFlow 2 from google colab
http://stackoverflow.com/questions/tagged/tensorflow-model-garden