Darknet: How to set anchors if they are "to big"

Created on 22 Feb 2019  路  5Comments  路  Source: AlexeyAB/darknet

Hi,

calculating the anchors i got:

anchors = 36, 35, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549

now all but 2 are bigger then 60x60.

i know its recommended to use the smaller anchors for the lower yolo layers.

What is recommended if there are only big anchors?

Explanations

Most helpful comment

@VisionEp1 Hi,

What is recommended if there are only big anchors?

  • Either just use all default anchors

  • Or add additional anchors with sizes 30,30, 60,60 - in your case 10 anchors in total instead of 9 anchors anchors = 36, 35, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549

And set masks:

[yolo]
mask = 2,3,4,5,6,7,8,9
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
...

[yolo]
mask = 1
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 60,60
...

[yolo]
mask = 0
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 30,30

All 5 comments

@VisionEp1 Hi,

What is recommended if there are only big anchors?

  • Either just use all default anchors

  • Or add additional anchors with sizes 30,30, 60,60 - in your case 10 anchors in total instead of 9 anchors anchors = 36, 35, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549

And set masks:

[yolo]
mask = 2,3,4,5,6,7,8,9
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
...

[yolo]
mask = 1
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 60,60
...

[yolo]
mask = 0
anchors = 30,30, 60,60, 82, 74, 126,143, 257,149, 186,273, 330,280, 329,510, 542,320, 546,549
num = 11
# will use anchors: 30,30

thanks!.
will try both

@AlexeyAB Hi, first of all, thank you for your repo.

I have a question however, when we are talking about an anchor larger or smaller than 60*60 or 30*30, by which measure we compare an anchor size with 60*60 or 30*30? If an anchor is 50*70, is this considered larger or smaller than 60*60?

And also, how do you decide the anchor size threshold for each yolo layer? Is this 30*30 and 60*60 only for 416*416 resolution? If I set with=736 and height=480 in .cfg file. How can I distribute anchors among 3 yolo layers?

Thanks!

@taosean

If I set with=736 and height=480 in .cfg file. How can I distribute anchors among 3 yolo layers?

In the same way. 15x15, 30x30, 60x60

If an anchor is 5070, is this considered larger or smaller than 6060?

You can compare 50x70=3500 and 60x60=3600

@AlexeyAB Thank you for your reply.

I'd like to know, what does 15x15 do? Since the 1st yolo layer applies anchors larger than 60x60. The 2nd yolo layer applies anchors between 30x30 and 60x60. The 3rd yolo layer applies anchors smaller than 30x30.
So what's the purpose of 15x15 here?

This is what you mentioned here

But you should change indexes of anchors masks= for each [yolo]-layer, so that 1st-[yolo]-layer has anchors larger than 60x60, 2nd larger than 30x30, 3rd remaining. Also you should change the filters=(classes + 5)* before each [yolo]-layer. If many of the calculated anchors do not fit under the appropriate layers - then just try using all the default anchors.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasleen137 picture jasleen137  路  3Comments

off99555 picture off99555  路  3Comments

hemp110 picture hemp110  路  3Comments

louisondumont picture louisondumont  路  3Comments

Yumin-Sun-00 picture Yumin-Sun-00  路  3Comments