tensorflow - 对象检测在笔记本电脑上运行非常缓慢
问题描述
我逐步完成了以下教程: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。我是否以次优方式导出了图表?我的机器是不是不够快?我仍然是一个初学者,所以任何方向都会非常有帮助 - 我可能会错过一些非常基本的东西。
解决方案
您首先运行的图表ssd_mobilenet_v1
花费了您大约 1 秒。另一张图faster_rcnn_resnet101
花了你大约 10 秒。他们两个是完全不同的架构。faster_rcnn_resnet101
运行速度会比ssd_mobilenet_v1
.
推荐阅读
- ios - 如何在 Swift 中设置时区
- java - Println 有两个条件
- java - 将 12 字符转换为长
- f# - 如何在 F# 中找到数组的第一个 NaN?
- python - 如何在codeigniter中调用python?
- android - 如何从 Android(kotlin)中 Firebase 提供的照片 uri 中检索和存储用户个人资料图片?
- python - 如何使用 CDK 部署 aws EventBridge - Python 示例
- javascript - 成功安装电子js有问题
- asynchronous - 如何知道 Mulesoft 异步范围何时完成
- android - 如何在 Android 上调试 Opera?