我正在尝试使用TensorFlow model zoo的ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8模型使用TensorFlow对象检测API进行对象检测。我能够使用ckpt文件检测单个测试图像(保存为ckpt-17.data-00000-of-00001)
我需要将此ckpt转换为一些保存的模型文件(.pb/.h5),以便在简单的flask webapp中使用。
我发现很难将ckpt文件转换为。pb使用下面的代码
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
当我试图转换为时,会出现以下错误。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.
如何保存检查点以供部署?
我正在使用谷歌colab的TensorFlow 2
http://stackoverflow.com/questions/tagged/tensorflow-model-garden
更正文件路径格式解决了问题:
!python /content/RealTimeObjectDetectionStages/Tensorflow/models/research/object_detection/model_main_tf2.py --model_dir=/content/RealTimeObjectDetectionStages/Tensorflow/workspace/models/my_ssd_mobnet --pipeline_config_path=/content/RealTimeObjectDetectionStages/Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config --num_train_steps=1000
问题内容: 我是Tensorflow的新手。我将训练后的模型保存为pb文件,我想使用tensorflow mobile,并且使用TFLITE文件很重要。问题是在谷歌搜索转换器后发现的大多数示例都是在终端或cmd上命令的。能否请您分享一个使用python代码转换为tflite文件的示例? 谢谢 问题答案: 在此TF示例之后,您可以传递“ –Saved_model_dir”参数以将save_model
如何将单对象转换为简单列表对象? 我使用下面的代码:
问题内容: 具有键值列表: … 如何使用Java 8 API将其转换为Multimap? 程序方式: 结果: {25 = [13,15],15 = [10,12]} 问题答案: 这正是收集器允许您执行的操作: 然后,收集器将对象转换为它们各自的值。
问题内容: 我正在尝试使用iText库将.txt文件转换为.pdf文件。我面临的问题如下: 我在txt文件中有清晰的格式,与此类似: 在输出中,格式消失了,看起来像这样: 代码如下: 我还尝试使用IDENTITY_H创建BaseFont,但是它不起作用。我猜这是关于编码或类似的东西。你怎么看?我用完了解决方案… 谢谢 LE:正如艾伦(Alan)以及iText页面上的教程所建议的那样,除了我现有的代
我有一个以以下格式返回json对象的响应: 我有一个Java类: 我想使用GSON将JSON对象映射到Java对象。 我尝试使用反序列化,它返回了JSON中嵌套值的。
我目前在转换张量流时遇到问题。pb模型到TFlite格式。我目前正在遵循谷歌代码实验室的指示,错误说 Traceback(最近调用的最后一次):文件/usr/local/bin/tflite_convert,第5行,在tensorflow.lite.python.tflite_convert导入主重要错误:没有模块命名lite.python.tflite_convert 我正在使用谷歌提供的命令