Google物体检测API:
根据谷歌研究论文,谷歌物体检测API支持的所有模型都具有实时性能!然而,上述测试代码显示,检测一个图像需要大约3秒钟(实际上,200帧-> 130秒,400帧-> 250秒)。我认为这个结果是错误的,因为这个模型具有实时性能。
可能的原因如下:
有关更多详细信息,请参阅以下链接https://github.com/tensorflow/models/issues/3531。
https://github.com/tensorflow/models/tree/master/research/object_detection
测试代码:
我按照以下步骤执行了Google物体检测API的测试代码:
with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
start = time.time()
image_tensor =
detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular
#object was detected.
detection_boxes =
detection_graph.get_tensor_by_name('detection_boxes:0')
detection_scores =
detection_graph.get_tensor_by_name('detection_scores:0')
detection_classes =
detection_graph.get_tensor_by_name('detection_classes:0')
num_detections =
detection_graph.get_tensor_by_name('num_detections:0')
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
image_np = load_image_into_numpy_array(image)
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
(boxes, scores, classes, num) = sess.run(
[detection_boxes, detection_scores, detection_classes,
num_detections], feed_dict={image_tensor: image_np_expanded})
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
np.squeeze(boxes),
np.squeeze(classes).astype(np.int32),
np.squeeze(scores),
category_index,
use_normalized_coordinates=True,
line_thickness=2)
print("--- %s seconds ---" % (time.time() - start))
根据谷歌研究论文,谷歌物体检测API支持的所有模型都具有实时性能!然而,上述测试代码显示,检测一个图像需要大约3秒钟(实际上,200帧-> 130秒,400帧-> 250秒)。我认为这个结果是错误的,因为这个模型具有实时性能。
可能的原因如下:
- GPU无法正常工作。
- 测试运行时间方法错误
有关更多详细信息,请参阅以下链接https://github.com/tensorflow/models/issues/3531。