【发布时间】:2020-01-01 12:35:43
【问题描述】:
我逐步完成了以下教程:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_pets.md
然后我尝试使用:https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb 运行推理
这运行得非常快(每张图像大约 1 秒)。我注意到代码正在从http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2017_11_17 拉下一个预训练模型(不是我在第一个教程中尝试过的模型)。
当我使用教程中导出的图表加载并执行推理时,大约需要 10 秒才能完成。我使用以下方法导出了图表:
python object_detection/export_inference_graph.py \
--input_type image_tensor \
--pipeline_config_path object_detection/samples/configs/faster_rcnn_resnet101_pets.config \
--trained_checkpoint_prefix model.ckpt-${CHECKPOINT_NUMBER} \
--output_directory exported_graphs
我正在使用此代码进行推理:
model = tf.saved_model.load(
os.path.join(os.getcwd(), 'exported_graphs', 'saved_model'))
model = model.signatures['serving_default']
output_dict = model(input_tensor)
我正在运行带有 HighSierra 的 MacOS。我是否以次优方式导出了图表?我的机器是不是不够快?我仍然是一个初学者,所以任何方向都会非常有帮助 - 我可能会错过一些非常基本的东西。
【问题讨论】:
标签: tensorflow