python - 预测模式下 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 + inception v2 input size
解决方案
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.
推荐阅读
- google-apps-script - .getCharts() 适用于个人 Gmail 但不适用于 Gsuite
- reactjs - 使用 React 和 SSR 时,什么会导致字体和图像被下载两次?
- c# - POST 成功后返回一个 Json 对象到 API 端点
- java - 如何在 java 中的凯撒加密中包含文件处理?
- javascript - JavaScript中的线线交叉点?
- spring - 使用 Spring WebClient 访问受 OAuth2 保护的资源,其中令牌提供程序也受 ssl 保护
- python - 如何使用 Python 在电子邮件 HTML 中嵌入多个图像
- ios - 为什么这个组合管道不让项目通过?
- vb.net - 有没有办法避免错误语句“算术运算导致溢出。”?
- python - 特定文件名的 Python 列表