我還在探索Tensorflow的Object Detection API。具體來說,我試圖微調現有的模型,以消除人爲檢測的誤報。
下面本文介紹了您所描述的相同目的硬負開採: Training Region-based Object Detectors with Online Hard Example Mining
在3.1節他們描述使用前景和背景類:
背景的投資回報。如果地帶真值的最大值IoU在區間[bg lo,0.5)中,則區域被標記爲背景(bg)。 FRCN和SPPnet都使用bg lo = 0.1的閾值較低的 ,並且在[14]中假設 粗略地近似硬性負採礦; 的假設是與地面實況有一些重疊的區域更可能是令人困惑或困難的區域。我們在第5.4節 中展示,儘管這種啓發式有助於收斂和檢測的準確性,但它並不是最理想的,因爲它忽略了一些不經常但很重要的困難背景區域。我們的方法刪除了bg lo閾值。
其實本文引用其想法是在難以開採Tensorflow的對象檢測losses.py代碼中使用:
class HardExampleMiner(object):
"""Hard example mining for regions in a list of images.
Implements hard example mining to select a subset of regions to be
back-propagated. For each image, selects the regions with highest losses,
subject to the condition that a newly selected region cannot have
an IOU > iou_threshold with any of the previously selected regions.
This can be achieved by re-using a greedy non-maximum suppression algorithm.
A constraint on the number of negatives mined per positive region can also be
enforced.
Reference papers: "Training Region-based Object Detectors with Online
Hard Example Mining" (CVPR 2016) by Srivastava et al., and
"SSD: Single Shot MultiBox Detector" (ECCV 2016) by Liu et al.
"""
基於模型的配置文件,該HardMinerObject由losses_builder返回。py在這段代碼中:
def build_hard_example_miner(config,
classification_weight,
localization_weight):
"""Builds hard example miner based on the config.
Args:
config: A losses_pb2.HardExampleMiner object.
classification_weight: Classification loss weight.
localization_weight: Localization loss weight.
Returns:
Hard example miner.
"""
loss_type = None
if config.loss_type == losses_pb2.HardExampleMiner.BOTH:
loss_type = 'both'
if config.loss_type == losses_pb2.HardExampleMiner.CLASSIFICATION:
loss_type = 'cls'
if config.loss_type == losses_pb2.HardExampleMiner.LOCALIZATION:
loss_type = 'loc'
max_negatives_per_positive = None
num_hard_examples = None
if config.max_negatives_per_positive > 0:
max_negatives_per_positive = config.max_negatives_per_positive
if config.num_hard_examples > 0:
num_hard_examples = config.num_hard_examples
hard_example_miner = losses.HardExampleMiner(
num_hard_examples=num_hard_examples,
iou_threshold=config.iou_threshold,
loss_type=loss_type,
cls_loss_weight=classification_weight,
loc_loss_weight=localization_weight,
max_negatives_per_positive=max_negatives_per_positive,
min_negatives_per_image=config.min_negatives_per_image)
return hard_example_miner
這是由model_builder.py返回並由train.py調用。所以基本上,在我看來,簡單地生成真正的正面標籤(使用像LabelImg或RectLabel這樣的工具)應該足以讓火車算法在相同的圖像中找到難以消除的負面信息。相關的問題給出了一個很好的walkthrough。我還沒有看到其他人提到自己必須產生負面影響。
如果您想要輸入沒有真實肯定的數據(即沒有圖像需要分類),我並不知道,我希望別人能夠提示是否需要。 PASCAL VOC提到了一個「其他」標籤ID 0,可以用來標註干擾標籤,但我沒有嘗試將0或0標籤作爲標籤。
請更新您找到的任何結果或任何您偶然發現的新信息。謝謝!