chr*_*ian 18 machine-learning object-detection computer-vision deep-learning tensorflow
我正在设置新的Tensorflow Object Detection API,以便在大面积的卫星图像中查找小物体.它工作得很好 - 它找到我想要的所有10个对象,但我也得到50-100个误报[看起来有点像目标对象的东西,但不是].
我使用的样本配置从"宠物"的教程,以微调的faster_rcnn_resnet101_coco
,它们的价格模型.我从小开始,只有100个我的对象训练样例(只有1个类).我的验证集中有50个示例.每个示例都是200x200像素的图像,中心带有标记对象(~40x40).我训练直到我的精确度和损失曲线高原.
我对使用深度学习进行物体检测相对较新.提高精度的最佳策略是什么?例如硬阴性采矿?增加我的训练数据集大小?我还没有尝试他们提供的最准确的模型,faster_rcnn_inception_resnet_v2_atrous_coco
因为我想保持一定的速度,但如果需要的话也会这样做.
硬负采矿似乎是合乎逻辑的一步.如果您同意,如何为我的训练数据集设置tfrecord文件?假设我为50-100个误报中的每一个制作200x200图像:
Tyl*_*ler 12
我最近在工作中重新讨论了这个话题,并且认为我将根据我目前对未来任何访问者的学习情况进行更新.
该主题出现在Tensorflow的模型回购问题跟踪器上.SSD允许您设置多少负面:postive示例与mine(max_negatives_per_positive: 3
)的比率,但您也可以设置没有postives(min_negatives_per_image: 3
)的图像的最小数量.这两个都在model-ssd-loss配置部分中定义.
也就是说,我在Faster-RCNN的模型配置中没有看到相同的选项.在问题中提到它models/research/object_detection/core/balanced_positive_negative_sampler.py
包含用于Faster-RCNN的代码.
该问题中讨论的另一个选择是创建专门用于类似的第二类.在培训期间,该模型将尝试学习应该有助于实现目的的阶级差异.
最后,我遇到了关于滤波器放大器网络(FAN)的这篇文章,它可能为您在航空影像方面的工作提供信息.
================================================== =================
以下文章描述了与您描述的相同目的的硬负面挖掘: 使用在线硬实例挖掘训练基于区域的对象检测器
在3.1节中,他们描述了使用前景和背景类:
背景RoIs.如果区域的最大IoU与地面实况在区间[bg lo,0.5]中,则区域标记为背景(bg).FRCN和SPPnet使用较低的bg lo = 0.1阈值,并在[14]中假设粗略接近硬负采矿; 假设与地面实况有一些重叠的区域更可能是混乱或困难的区域.我们在5.4节中表明,虽然这种启发式方法有助于收敛和检测准确性,但它不是最理想的,因为它忽略了一些不常见但很重要的困难背景区域.我们的方法删除了bg lo阈值.
事实上,本文被引用,其思想用于Tensorflow的对象检测loss.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.
"""
Run Code Online (Sandbox Code Playgroud)
根据您的模型配置文件,在这段代码中,loss_builder.py返回HardMinerObject:
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
Run Code Online (Sandbox Code Playgroud)
由model_builder.py返回并由train.py调用.所以基本上,在我看来,简单地生成真正的正面标签(使用像LabelImg或RectLabel这样的工具)应该足以使列车算法在相同的图像中找到硬阴性.相关问题提供了一个很好的演练.
如果您想要输入没有真正正面的数据(即图像中没有任何内容),只需将负图像添加到tfrecord,不带边界框.