首页 > 解决方案 > 预测模式下 tensorflow faster-rcnn 的输入图像大小?

问题描述

我刚刚使用 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})

相关:训练图像大小 Faster-RCNN

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

标签: pythontensorflowobject-detection-api

解决方案


In Feature Pyramid Networks for Object Detection, Faster RCNN shows different mAP on object of different size. The model has higher mAP on large objects than on small objects. In Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks, faster RCNN resizes input images such that their shorter side is 600 pixels. Thus, in my option, relative size of objects in images does matter in detection. Cropping a large image and use the smaller image as input may facilitate the detection of small objects in the raw image for small objects become relatively large objects in the new image.

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

推荐阅读