mAP decreasing with training tensorflow object detection SSD

时间:2018-02-03 07:59:49

标签: tensorflow object-detection

I'm trying to train a SSD mobilenet detector for detecting cell nuclei in microscopic images. I'm using the tensorflow object detection API on Ubuntu 16.04 with the GPU implementation of tensorflow (version 1.4). My input images are 256x256 RGB jpg tiles with annotated cell nuclei.

When I start training I see a nice increase in mAP and at about 6k global steps (batch size 12) I can detect most cell nuclei, but with some multiple detections of the same cell nuclei.

Weirdly, after this point mAP starts decreasing and the model detects less and less cell nuclei even though the TotalLoss continues to decrease. At 100k steps, almost no nuclei are detected.

I use the standard config file for SSD except that I've decreased the cutoff for matched/unmatched boxes. If I don't use this modification the model has difficulties detecting any cell nuclei because they are smallish objects and too few boxes overlap them.

matcher {
  argmax_matcher {
    matched_threshold: 0.3
    unmatched_threshold: 0.3
    ignore_thresholds: false
    negatives_lower_than_unmatched: true
    force_match_for_each_row: true
  }

Why is it that mAP and detection accuracy decrease over time even though TotalLoss improves? My intuition of the results is that the detection model is getting more and more accurate (never a false positive) but less and less sensitive (lots of false negatives).

Any suggestions greatly appreciated!

(here are some example images from tensorboard)

0 steps

1241 steps

53024 steps

92176 steps

1 个答案:

答案 0 :(得分:5)

好的,所以经过对配置文件的一些实验(=盲猜)我觉得我找到了我的问题的答案 - 我把它放在这里希望别人可以受益。

首先,mAP减少的原因可能是设置:

matched_threshold: 0.3
unmatched_threshold: 0.3

从我的实验中,将此设置(如我所做的)降低到0.5以下似乎会破坏模型的稳定性并使其在训练期间中断(随着时间的推移mAP减少)。

其次,当试图在显微图像中检测细胞核时(这可能也适用于具有已知大小的其他小物体),SSD似乎对锚生成器中的最小/最大设置非常敏感。

anchor_generator {
  ssd_anchor_generator {
    num_layers: 6
    min_scale: 0.2
    max_scale: 0.95

当我开始(并经常失败)时,我使用了球场估计这个设置,当玩不同的图像大小等时,突然在128x128像素,模型非常好用mAP 0.9检测或多或少每个细胞。当我试图找出它突然发生的原因时,我在图像中的注释对象的相对大小上打印了直方图,我意识到我对128x128模型的配置文件很幸运并且精确地达到了范围。

然后我又回到了所有其他型号和尺寸,当在特定图像尺寸中使用细胞核的确切尺寸范围时,该模型即使在更大的图像尺寸(例如512px)处也能完美呈现仅占图像宽度的3-15%。即使在1024px时,下采样到512并且原子核仅覆盖1-7%的图像宽度,只要精确指定了尺寸范围,模型就可以正常工作。

对于我的应用程序,这实际上不是问题,因为我事先知道要期望的功能大小,但是有一个更普遍的问题,我猜它是一个弱点..