【问题标题】:visualize boxes in tensorflow object detection可视化张量流对象检测中的框
【发布时间】: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


【解决方案1】:

您将 image_np 值作为第一个参数传递给visualize_boxes_and_labels_on_image_array,该函数会修改其内容以绘制边界框。代码是开源的。你可以自己去看看here.

【讨论】:

    猜你喜欢
    • 2018-01-10
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 2021-04-03
    • 2019-02-12
    • 2018-03-12
    • 2020-07-06
    相关资源
    最近更新 更多