小编Ste*_*ley的帖子

如何可视化TFRecord?

有人在另一个论坛上问我这个问题,但我想将它发布给任何在TFRecords上遇到麻烦的人。

如果TFRecord文件中的标签与labels.pbtxt文件中的标签不对齐,TensorFlow的对象检测API可能会产生奇怪的行为。它会运行,损失可能会减少,但网络将无法产生良好的检测结果。

另外,我总是会在XY,行列空间之间感到困惑,因此我总是想仔细检查以确保我的注释实际上在注释图像的正确部分。

我发现最好的方法是解码TFRecord并用TF工具绘制它。下面是一些代码:

import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from object_detection.utils import visualization_utils as vu
from object_detection.protos import string_int_label_map_pb2 as pb
from object_detection.data_decoders.tf_example_decoder import TfExampleDecoder as TfDecoder
from google.protobuf import text_format
def main(tfrecords_filename, label_map=None):
    if label_map is not None:
        label_map_proto = pb.StringIntLabelMap()
        with tf.gfile.GFile(label_map,'r') as f:
            text_format.Merge(f.read(), label_map_proto)
            class_dict = {}
            for entry in label_map_proto.item:
                class_dict[entry.id] = {'name':entry.display_name}
    sess = tf.Session()
    decoder = TfDecoder(label_map_proto_file=label_map, use_display_name=False)
    sess.run(tf.tables_initializer())
    for record in tf.python_io.tf_record_iterator(tfrecords_filename):
        example = decoder.decode(record) …
Run Code Online (Sandbox Code Playgroud)

python object-detection tensorflow tfrecord

12
推荐指数
2
解决办法
980
查看次数

在 Tensorflow 对象检测 API 中定义 GPU 选项

我能够在具有 4x 1080Ti 的本地机器上进行训练,正如其他人指出的那样,TF 会占用我机器上的所有可用内存。经过一番探索后,大多数搜索都让我找到了基本 TF 的解决方案,而不是对象检测 API,例如:

如何防止 TensorFlow 分配全部 GPU 内存?

如何在对象检测 API 中访问这些类型的选项?如何在 OD API 中对训练进行类似 TF 风格的控制?在 OD API / slim API 中是否有正确的方法?

我尝试向该 Training.proto 添加 GPUOptions 消息,但这似乎没有什么区别。

tensorflow object-detection-api

4
推荐指数
1
解决办法
3486
查看次数