1. 程式人生 > >YOLOv2和YOLOv3的anchor大小有什麼區別?

YOLOv2和YOLOv3的anchor大小有什麼區別?

在YOLOv2中,作者用最後一層feature map的相對大小來定義anchor大小。也就是說,在YOLOv2中,輸入影象大小為416*416,下采樣32倍得到最後一層feature map大小為13X13,相對的anchor大小範圍就在(0x0,13x13],如果一個anchor大小是9x9,那麼其在原圖上的實際大小應該放大32倍,就是288x288.

而在YOLOv3中,作者又改用相對於原圖的大小來定義anchor,anchor的大小為(0x0,input_w x input_h]。需要注意的是,當你的訓練集的大小不是416X416時,anchor應當是轉換為416X416後的聚類結果。

所以,在兩份cfg檔案中,anchor的大小有明顯的區別。如下是作者自己的解釋: So YOLOv2 I made some design choice errors, I made the anchor box size be relative to the feature size in the last layer. Since the network was down-sampling by 32. This means it was relative to 32 pixels so an anchor of 9x9 was actually 288px x 288px.

In YOLOv3 anchor sizes are actual pixel values. this simplifies a lot of stuff and was only a little bit harder to implement.