Keras-retinanet: Number of anchors per image

Created on 15 Nov 2017  路  2Comments  路  Source: fizyr/keras-retinanet

I'm trying to understand how the anchor box proposals are being generated and it seems like calling anchors.anchor_targets(...) generates 2196 anchor targets. The paper describes having 100k anchor boxes per input image. Am I missing something?

Most helpful comment

It depends on the shape of the image you provide as input. The image shape is reduced to 1/8 its original size for the first pyramid level, then for each pixel in that reduced image shape, 9 anchors are created. Say your image is shaped 512x512, this means the reduced image shape is 64x64, so 64x64x9 anchors are added for the first pyramid level. The image shape is then reduced again for the second pyramid, so 32x32x9 anchors are added and so on. The total sum of anchors would be:

(64^2 + 32^2 + 16^2 + 8^2 + 4^2) * 9 = 49104

In a more realistically shaped image (say (600, 1000)) the math would turn out like:

(600/8 * 1000/8 + 600/16 * 1000/16 + 600/32 * 1000/32 + 600/64 * 1000/64 + 600/128 * 1000/128) * 9 = 112390

Which is close to the magical 100k they mention in the paper :)

All 2 comments

It depends on the shape of the image you provide as input. The image shape is reduced to 1/8 its original size for the first pyramid level, then for each pixel in that reduced image shape, 9 anchors are created. Say your image is shaped 512x512, this means the reduced image shape is 64x64, so 64x64x9 anchors are added for the first pyramid level. The image shape is then reduced again for the second pyramid, so 32x32x9 anchors are added and so on. The total sum of anchors would be:

(64^2 + 32^2 + 16^2 + 8^2 + 4^2) * 9 = 49104

In a more realistically shaped image (say (600, 1000)) the math would turn out like:

(600/8 * 1000/8 + 600/16 * 1000/16 + 600/32 * 1000/32 + 600/64 * 1000/64 + 600/128 * 1000/128) * 9 = 112390

Which is close to the magical 100k they mention in the paper :)

Thanks for clarifying :)

Was this page helpful?
0 / 5 - 0 ratings