Tensorflow 对象检测 API:如何使用不包含任何标签(硬底片)的图像创建 tfrecords? [英] Tensorflow Object Dectection API : how to create tfrecords with images not containing any labels (hard negatives)?

查看:22
本文介绍了Tensorflow 对象检测 API:如何使用不包含任何标签(硬底片)的图像创建 tfrecords?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

我目前在我自己的数据集上使用 tensorflow 对象检测 API(带有 Faster Rcnn),对于我的一些标签,我已经识别出很可能被检测为误报的对象,并且我知道该 API 使用硬样本挖掘,所以我要做的是将包含这些硬对象的图像引入训练,以便矿工可以将它们作为硬底片.

I am currently using tensorflow object detection API(with Faster Rcnn)on my own dataset, for some of my labels, i've identified objects that are very likely to be detected as false positives, and i know that the API uses hard exemples mining, so what i'am trying to do it is to introduce images that contain these hard objects into the training , so that the miner can take them as hard negatives.

关注此对话github https://github.com/tensorflow/models/issues/2544 我是说有可能

following this conversation on github https://github.com/tensorflow/models/issues/2544 I was told that it's possible

你可以有纯粹的负图像,faster_rcnn 模型将采样来自他们的锚点.

You can have purely negative images and faster_rcnn models will sample from anchors from them.

所以我的问题是:如何使用一些没有任何边界框的图像创建 tfrecords?我在关联的 .xml 文件中放了什么?

So my question is : how do i create tfrecords with some images not having any bounding boxes ? What do i put in the associated .xml files?

推荐答案

在你的 tfrecords 生成脚本中,确保你像这样将硬负图像的元数据添加到 tf 记录 -

In your tfrecords generation script make sure you add the metadata of the hard negative image to tf record like this -

tf_example = tf.train.Example(features=tf.train.Features(feature={
            'image/height': dataset_util.int64_feature(height),
            'image/width': dataset_util.int64_feature(width),
            'image/filename': dataset_util.bytes_feature(filename),
            'image/source_id': dataset_util.bytes_feature(filename),
            'image/encoded': dataset_util.bytes_feature(encoded_jpg),
            'image/format': dataset_util.bytes_feature(image_format)
            }))

对于带有对象的图像,您还必须添加边界框和标签信息 -

For an image with objects you must add the bounding boxes and label information as well -

tf_example = tf.train.Example(features=tf.train.Features(feature={
            'image/height': dataset_util.int64_feature(height),
            'image/width': dataset_util.int64_feature(width),
            'image/filename': dataset_util.bytes_feature(filename),
            'image/source_id': dataset_util.bytes_feature(filename),
            'image/encoded': dataset_util.bytes_feature(encoded_jpg),
            'image/format': dataset_util.bytes_feature(image_format),
            'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
            'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
            'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
            'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
            'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
            'image/object/class/label': dataset_util.int64_list_feature(classes),
        }))

还要确保在 pipeline.config 文件中将 min_negatives_per_image 设置为正数,否则它不会使用负图像进行训练

Also make sure you set min_negatives_per_image to a positive number in your pipeline.config file otherwise it won't train with negative images

这篇关于Tensorflow 对象检测 API:如何使用不包含任何标签(硬底片)的图像创建 tfrecords?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆