源码分析-TensorFlow目标检测API

参考:

[1]TensorFlow Object Detection API: basics of detection:

https://becominghuman.ai/tensorflow-object-detection-api-basics-of-detection-7b134d689c75

https://becominghuman.ai/tensorflow-object-detection-api-basics-of-detection-2-2-28b348495eec

resize后的输入图像大小

config文件中的第43-47行,修改参数image_resizer

anchor box

源码在anchor_generators文件夹下,config文件中第31-41行修改参数anchor_generator

  • anchor box的ratio设置,可参考SSD的中心对称设置,如2与1/2

loss函数

loss的更改只需在config修改即可,源码对应loss.py中的108行;

==但,为啥默认的分类loss为sigmoid loss,而原文中是softmax?==

hard negtive mining难例挖掘

在所有预测的anchor box中,只有少部分的anchor box是与ground trut匹配的。大部分anchor box与ground truth的重叠比例小于都一定的阈值,因此会有大量的anchor box都是negtive的,这会导致正负样本比例失调;

取未匹配的box中,分类loss从大到到小前k个box的分类loss用于反向传播,以保证正负样本的比例基本固定,这也被叫做online hard-negative mining

原文中设置k值,使得负样本和正样本比例为3:1

源码在loss.py中,config文件中第119行修改参数num_hard_examples

NMS非极大值抑制

config文件中第130-136行修改参数batch_non_max_suppression中的score_threshold,iou_threshold