【问题标题】:Input image size for tensorflow faster-rcnn in prediction mode?预测模式下 tensorflow faster-rcnn 的输入图像大小?
【发布时间】:2020-01-20 22:29:45
【问题描述】:

我刚刚使用 tensorflow 对象检测 api 使用 fast-rcnn 进行了一些迁移学习。我在tensorflow 1.14,骨干网是faster_rcnn_resnet101_coco。冻结网络在进行预测时是否会调整提供给它们的图像的大小?

我问是因为当我为模型提供比我训练的图像大得多的图像时,它无法识别任何物体。当我将图像裁剪为 1200x1200 时,对象都是相同的,但效果很好。

模型是否包含图像大小限制?我是否应该使用与配置文件中相似的尺寸进行预测,即使对象在 3000x3000 图像中的大小相同?

在用于训练的配置文件中,我对输入图像进行了约束:

image_resizer {
  keep_aspect_ratio_resizer {
    min_dimension: 200
    max_dimension: 1200
  }
}

这是否意味着在我现在使用的经过训练的模型中,如果我给它提供大于 1200x1200 的图像,它会缩小它吗?以下是我如何在加载的冻结模型中进行预测:

with model.as_default():
        with tf.Session(graph=model) as sess:
            imageTensor = model.get_tensor_by_name("image_tensor:0")
            boxesTensor = model.get_tensor_by_name("detection_boxes:0")
            scoresTensor = model.get_tensor_by_name("detection_scores:0")
            classesTensor = model.get_tensor_by_name("detection_classes:0")
            numDetections = model.get_tensor_by_name("num_detections:0")

            # Make prediction
            (boxes, scores, labels, N) = sess.run([boxesTensor, scoresTensor, classesTensor, numDetections],
                                                   feed_dict = {imageTensor: image})

相关:Training Image Size Faster-RCNN

另外,这篇文章让我觉得它应该处理任何输入大小,但它显然不能处理它们,所以我很困惑:Faster RCNN + inception v2 input size

【问题讨论】:

    标签: python tensorflow object-detection-api


    【解决方案1】:

    Feature Pyramid Networks for Object Detection 中,Faster RCNN 在不同大小的对象上显示不同的 mAP。该模型在大物体上的 mAP 比在小物体上的更高。在Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks 中,faster RCNN 会调整输入图像的大小,使其短边为 600 像素。因此,在我的选择中,图像中对象的相对大小在检测中确实很重要。裁剪大图像并使用较小的图像作为输入可能有助于检测原始图像中的小物体,因为小物体在新图像中变成相对较大的物体。

    FPN in a basic Faster R-CNN system has different performance on small, middle and large objects.

    1. Discussion on GitHub
    2. Another discussion on GitHub

    【讨论】:

      猜你喜欢
      • 2021-11-02
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 2021-03-03
      • 2020-12-24
      • 2017-05-12
      • 2020-06-17
      相关资源
      最近更新 更多