首页 > 解决方案 > YOLO and adjusting number of anchor boxes for custom dataset

问题描述

I am working on implementing YOLO v2 and 3 for object detection on a custom dataset. While YOLO v2 and 3 use something like 5 or so anchor boxes, I generally have maybe 50-100 detections each image. My sense is that if there are only 5 anchor boxes, then there are at most 5 detections per image right? So I was trying to understand if I needed to adjust the number of anchor boxes to my dataset.

My questions is, does the number of anchor boxes need to be larger than the maximum count of bounding boxes in any training image? That way, I would never run into detections where there is no corresponding anchor box. Is that the right way of thinking about adapting YOLO?

If my intuition is correct then would I need to do k-means to cluster the bounding boxes in the ground truth images and set the anchor box coordinates. Then I would use the usual regression method as specified in this blog post.

Thanks for any help that anyone can provide.

标签: tensorflowkerasobject-detectionconvolutional-neural-networkyolo

解决方案


我的感觉是,如果只有 5 个锚框,那么每个图像最多有 5 次检测,对吧?

每个预测单元有五个锚框,而不是整个图像。让我们考虑 Yolo v2,其中输入图像的大小为416x416x3,输出为13x13xN. 每个 13x13 对应于输入图像中的一个 32x32 单元区域(如下图所示来自博客文章),并且对于每个 13x13 单元,定义了 5 个锚点。因此,从技术上讲,您可以为大小为 416x416 的图像设置 13x13x5 的边界框(您也可以使用更大的图像进行训练,因为 yolo v2 是一个完全卷积的网络,然后您可以获得更多的细胞区域)。 在此处输入图像描述

假设您的图像中有 50 个边界框,每个边界框应根据边界框中心与单元格中心的接近程度分配给一个单元格。现在,对于这个单元格,选择 5 个提供最佳 IOU 的锚框之一。为每个单元构建一个标签,该标签应包含所有 5 个锚框的置信度分数和框位置和尺寸(除了选择的锚框,其他将标记为零)以及类分数。

在链接中提到的 k-means 聚类中,它描述了它们是如何到达五个锚框的。最好只使用 5 个边界框,除非您有任何具体原因要包含更多或在出现任何特定要求时具有不同的形状。


推荐阅读