CV_Dreamer anchor box之 SSD default boxes
1.关于default boxes和anchor boxes
在SSD中,作者使用了default boxes或default bounding boxes。SSD与YOLOV3有类似的结构,即multi-scale feature maps+default boxes of different scales and aspect ratios。不同的是,YOLOV3中使用了anchor boxes的概念,而SSD中却强调是default boxes。其实是一回事,不用太过计较。
2.multi-scale feature maps以及default boxes
从上图可以看出,SSD原始实现backbone采用了VGG-16,同时添加了Extra Feature Layers。输出default box的特征图(feature map)的size有[38, 19, 10, 5, 3, 1],各特征图(Conv4_3,Conv7,Conv8_2,Conv9_2,Conv10_2,Conv11_2)相应的default box的个数分别为[4,6,6,6,4,4]。因此SSD模型输出的default box的个数总共有:
。
有的特征图是4个box,有的是6个,那么又是如何构造的呢?
接线来将参考知乎JimmyHua及GitHub中amdegroot的实现细致剖析。
3.default box的实现
不同版本的实现可能会略有不同,这里结合amdegroot/ssd.pytorch详细介绍SSD-300(输入尺寸300*300)default boxes实现方案。
3.1 不同default box的scale
对于Conv4_3,scale对应于原图,即接下来讲的 s _{min} =0.1;
对于其他5个feature map:
,
其中,
这样可以计算出相对于原图,Conv7,Conv8_2,Conv9_2,Conv10_2,Conv11_2的scale分别为:。
另外对于aspect ratio为1的情况,增加了一个box,其scale:。
对应原图尺寸分别为:
。
而Conv4_3,对应的为60。
总结起来,6个feature map各Scale对应原图分别为:
;
,
就可以相应计算出来了。
3.2 default box的aspect ratios
SSD选用了6种aspect ratios:
,其中代表aspect ratio为1时补充的那个box。
对于只有4个box的feature map,。
各box scale有了,ratio也有了,接下来就可以计算宽和高了。
对于每一种ratio:
。
接线来是其中心点的坐标:
按照论文中的说法,是第k个feature map的size。
但在amdegroot github中,其计算如下:
steps= [8, 16, 32, 64, 100, 300],
= img_size/steps[k]。
其实二者差不多。
到这里,default box的实现就讲完了。4个default box为什么缺了的ratio,经验值还是什么原因,并没有找到合理的解释,结论在作者论文“3.1 PASCAL VOC2007”节中有提到"For conv4_3,conv10 2 and conv11 2, we only associate 4 default boxes at each feature map location– omitting aspect ratios of 1/3 and 3"。有答案的高手,欢迎告知。
3.3 再看下这张经典的图片
之所以经典,我个人觉得是比较直观的告诉我们,小feature map适合大目标的检测,大feature map便于小目标的检测。
参考文件
[1]知乎-【SSD算法】史上最全代码解析-核心篇
[2]SSD: Single Shot MultiBox Detector
[3]https://github.com/amdegroot/ssd.pytorch