【问题标题】:Trouble evaluating test data with Tensorflow's Object Detection API使用 TensorFlow 的对象检测 API 评估测试数据时遇到问题
【发布时间】:2019-01-08 19:14:41
【问题描述】:

概述

我正在使用Tensorflow's Object Detection API 使用自定义训练数据开发对象检测器。到目前为止,我的理解是我可以将我的训练数据输入模型,然后使用经过训练的模型 [0] 来评估测试数据,并且在评估之后,我将能够看到如下一组图像找出经过训练的模型能够在我的测试数据中的每张图像中检测到什么。

到目前为止我做了什么

在这个假设下,我已经能够创建一个.tfrecord 格式的训练数据集,并且我已经能够使用以下命令将其输入到我的模型训练器中:

PIPELINE_CONFIG_PATH="nbl-tf-test.config"
MODEL_DIR="./object_detection/modeldir"
NUM_TRAIN_STEPS=50000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1

python3 object_detection/model_main.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --num_train_steps=${NUM_TRAIN_STEPS} \
    --sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES \
    --alsologtostderr

这给了我这样的输出(重复了很多次——这只是一个代表性示例):

2019-01-08 00:47:31.007154: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2019-01-08 00:47:31.007931: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-01-08 00:47:31.007957: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0
2019-01-08 00:47:31.007964: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N
2019-01-08 00:47:31.008119: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 5278 MB memory) -> physical GPU (device: 0, na
me: Tesla K20Xm, pci bus id: 0000:02:00.0, compute capability: 3.5)
creating index...
index created!
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=17.90s).
Accumulating evaluation results...
DONE (t=2.83s).
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.007
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.020
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.003
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.006
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.008
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.018
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.089
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.485
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.015
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.367
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.573
creating index...
index created!
creating index...
index created!
Running per image evaluation...
Evaluate annotation type *bbox*
DONE (t=17.94s).
Accumulating evaluation results...
DONE (t=2.86s).

本次培训结束后,我在object_detection/modeldir目录中找到了一组文件:

$ ls modeldir
checkpoint                              model.ckpt-308.meta
eval_0                                  model.ckpt-485.data-00000-of-00001
events.out.tfevents.1546897788.moose55  model.ckpt-485.index
export                                  model.ckpt-485.meta
graph.pbtxt                             model.ckpt-664.data-00000-of-00001
model.ckpt-1000.data-00000-of-00001     model.ckpt-664.index
model.ckpt-1000.index                   model.ckpt-664.meta
model.ckpt-1000.meta                    model.ckpt-844.data-00000-of-00001
model.ckpt-308.data-00000-of-00001      model.ckpt-844.index
model.ckpt-308.index                    model.ckpt-844.meta

我的问题

我应该如何处理这个目录的内容来测试我的测试数据?我假设我必须有一个用于所有测试数据的.tfrecord 文件(类似于我之前为训练数据制作的文件)。基于the model's documentation,我一直在尝试运行以下命令:

python3 object_detection/inference/infer_detections.py \
  --input_tfrecord_paths=output.tfrecord \
  --output_tfrecord_path=detections.tfrecord \
  --inference_graph=object_detection/modeldir-8steps/graph.pbtxt \
  --discard_image_pixels

但是当我这样做时,我遇到了以下错误(同时运行 Python 2 和 Python 3):

INFO:tensorflow:Reading graph and building model...
Traceback (most recent call last):
  File "object_detection/inference/infer_detections.py", line 96, in <module>
    tf.app.run()
  File "/usr/lib/python3.4/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "object_detection/inference/infer_detections.py", line 74, in main
    image_tensor, FLAGS.inference_graph)
  File "/home/jlittle/honors/5-tf-nbl-clean-setup/object_detection/inference/detection_inference.py", line 71, in build_inference_graph
    graph_def.MergeFromString(graph_content)
TypeError: 'str' does not support the buffer interface

有谁知道:

  1. 如果我上面给出的概述是正确的?如果是这样,
  2. 如果这是我应该运行的正确评估 python 脚本?如果是的话,
  3. 如果我提供给脚本的数据有任何问题,是否会出现上述错误?最后,
  4. 如果这是开展此项目的最佳方式,或者如果我离基地很远,应该考虑其他事情?

谢谢。


[0]:这是正确的词汇吗,像这样以两种不同的方式使用 model?

【问题讨论】:

  • 您可能需要导出推理图以对新图像运行检测。 Here 是 TF 文档。

标签: python tensorflow object-detection object-detection-api


【解决方案1】:

我的理解是错误的。 model_main.py 程序是独立的;它执行训练和评估步骤,之后我不需要对该目录执行任何操作。查看测试输出所需要做的就是将 TensorBoard 实例附加到模型目录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-07
    • 1970-01-01
    • 2019-03-03
    • 2020-08-23
    • 2020-03-04
    • 1970-01-01
    • 2020-06-03
    • 2017-11-27
    相关资源
    最近更新 更多