简体   繁体   English

Yolov3中的自定义锚点

[英]Custom anchors in Yolov3

I'm training an object detector using Yolov3 on my custom dataset.我正在我的自定义数据集上使用 Yolov3 训练 object 检测器。 Traditionally in Yolo you have a variety of object classes so you get a good mix of anchors.传统上,在 Yolo 中,您有各种 object 类,因此您可以获得很好的锚点组合。 In my case, I only have one object class and it has pretty similar dimensions.就我而言,我只有一个 object class 并且它的尺寸非常相似。 So when I cluster the dimensions using K-means, I get 9 anchors of pretty similar size... which seems counterproductive.因此,当我使用 K-means 对维度进行聚类时,我得到了 9 个大小非常相似的锚点……这似乎适得其反。

In fact, I tried with some random anchor sizes that are not all similar and got better results than with 9 similar anchors.事实上,我尝试了一些不完全相似的随机锚点大小,并且比使用 9 个相似的锚点获得了更好的结果。 So I wonder, what's the best strategy for anchors for 1 class object detector?所以我想知道,1 class object 检测器的最佳锚点策略是什么?

This is what author says about anchor boxes here :这就是作者在这里所说的关于锚框的内容:

Only if you are an expert in neural detection networks - recalculate anchors for your dataset for width and height from cfg-file: darknet.exe detector calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416 then set the same 9 anchors in each of 3 [yolo]-layers in your cfg-file.仅当您是神经检测网络专家时 - 从 cfg 文件重新计算数据集的宽度和高度的锚点:darknet.exe 检测器 calc_anchors data/obj.data -num_of_clusters 9 -width 416 -height 416 然后设置相同的 9 个锚点在 cfg 文件的 3 个 [yolo] 层中的每一个中。 But you should change indexes of anchors masks= for each [yolo]-layer, so for YOLOv4 the 1st-[yolo]-layer has anchors smaller than 30x30 , 2nd smaller than 60x60 , 3rd remaining, and vice versa for YOLOv3 .但是您应该更改每个 [yolo] 层的锚点 mask= 的索引,因此对于YOLOv4 ,第一个 [yolo] 层的锚点小于30x30 ,第二个小于60x60 ,剩余第三个,反之亦然YOLOv3 Also you should change the filters=(classes + 5)* before each [yolo]-layer.此外,您应该在每个 [yolo] 层之前更改 filters=(classes + 5)*。 If many of the calculated anchors do not fit under the appropriate layers - then just try using all the default anchors.如果许多计算出的锚点不适合适当的层 - 那么只需尝试使用所有默认锚点。

So to train single class object detector where in object dimensions are pretty similar, then:因此,要训练单个 class object 检测器,其中 object 的尺寸非常相似,然后:

  1. Use default anchor boxes as stated above如上所述使用默认锚框
  2. Use random=0 in the cfgcfg中使用random=0

To understand anchor box concept, go through this discussion.通过这个讨论来理解锚盒的概念,go。

Also since Yolov4 is available now, suggest you to use that for better accuracy / mAP .此外,由于Yolov4现在可用,建议您使用它以获得更好的accuracy / mAP If you want to stick to Yolov3 , use Yolov3-spp or Yolov3_5l for improved results.如果您想坚持使用Yolov3 ,请使用Yolov3-sppYolov3_5l以获得更好的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM