【发布时间】:2018-08-03 04:03:31
【问题描述】:
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
output_dict = run_inference_for_single_image(image_np, detection_graph)
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
output_dict['detection_boxes'],
output_dict['detection_classes'],
output_dict['detection_scores'],
category_index,
instance_masks=output_dict.get('detection_masks'),
use_normalized_coordinates=True,
line_thickness=8)
plt.figure(figsize=IMAGE_SIZE)
plt.imshow(image_np)
在 tensorflow 对象检测 API 的代码之一中,有 vis_util.visualize_boxes_and_labels_on_image_array 方法,它在图像上绘制边界框并返回新的 image_np,它被输入 plt.imshow(image_np) 进行显示。但是,vis_util.visualize_boxes_and_labels_on_image_array 方法没有分配给 image_np 变量,如代码所示。 plt.imshow(image_np) 如何获取最新的(已绘制边界框的图像)图像?
【问题讨论】:
-
但是应该是image_np = vis_util.visualize_boxes_and_labels_on_image_array(......),那么函数可以返回新修改的内容吗?
-
没有。您正在传递一个数组。数组中的内容(图像像素)被修改。
-
好的,非常感谢。我是 python 新手,哈哈
标签: python tensorflow