【问题标题】:What's the output of YOLO?YOLO 的输出是什么?
【发布时间】:2021-01-21 01:41:53
【问题描述】:

我正在尝试使用 YOLO 来检测 Android 应用程序中的车牌。

所以我在 Google Colab 中训练了一个 YOLOv3 和一个 YOLOv4 模型。我使用wonderfull project of Hunglc007 将这两个模型转换为 TensorFlow Lite,我还验证了它们是否正常工作并得到以下结果:

但是当我尝试了解模型的输出以在我的应用中调整它时,我使用netron 得到了这个:

当模型被训练为只检测一个对象时,为什么我有 2 个输出?

为什么输出的格式是这样的,这个[1,1,4]代表什么?

编辑

bbox的代码可以在here找到

boxes, scores, classes, valid_detections = tf.image.combined_non_max_suppression(
            boxes=tf.reshape(boxes, (tf.shape(boxes)[0], -1, 1, 4)),
            scores=tf.reshape(
                pred_conf, (tf.shape(pred_conf)[0], -1, tf.shape(pred_conf)[-1])),
            max_output_size_per_class=50,
            max_total_size=50,
            iou_threshold=FLAGS.iou,
            score_threshold=FLAGS.score
        )
        pred_bbox = [boxes.numpy(), scores.numpy(), classes.numpy(), valid_detections.numpy()]
        image = utils.draw_bbox(original_image, pred_bbox)
        # image = utils.draw_bbox(image_data*255, pred_bbox)
        image = Image.fromarray(image.astype(np.uint8))
        image.show()
        image = cv2.cvtColor(np.array(image), cv2.COLOR_BGR2RGB)
        cv2.imwrite(FLAGS.output + 'detection' + str(count) + '.png', image)

【问题讨论】:

  • 您能否提供有关您自己的代码的更多信息,例如显示最后一个数字的部分。
  • 带有 bbox 的图像的代码或输入和输出信息的代码?
  • 生成这个的代码。 i.stack.imgur.com/hYtkT.png
  • 它是lutzroeder.github.io/netron 我在编辑中添加它。它是一个了解模型输入和输出的工具。您只需将 .tflite 放入其中,它就会为您提供所需的所有信息

标签: tensorflow-lite yolo


【解决方案1】:

我不是 Netron 方面的专家,但通过检查问题及其预期输出,我发现它应该为每次检测产生两个输出;检测矩形和检测置信度。因此,您询问的两个输出可能是由 4 个浮点数定义的矩形 - 左上角、宽度和高度的两个坐标 - 以及一个浮点数的置信度。

【讨论】:

    【解决方案2】:

    这很明显。用于检测模型。通常,它应该至少给出 2 个输出:边界框和与边界框相关的类。 因此,(1,1,4) 是边界框的 4 结果。第一个数字 1 是根据您将图像提取到模型中的。由于您只有一个对象,因此第二个数字的输出为 1。此外,边界框的 YOLO 配置为 (x_center,y_center,width,height)

    (1,1,1) 将是相同的,但现在 1 是您选择的类的标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-22
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多