如何在Tensorflow对象检测API中评估预训练模型

jay*_*713 5 object-detection deep-learning tensorflow

尝试使用最近发布的Tensorflow对象检测API,想知道如何评估他们在模型动物园中提供的一种预训练模型?例如 如何获得该预训练模型的mAP值?

由于他们提供的脚本似乎使用了检查点(根据他们的文档),所以我尝试制作一个检查点的哑副本,该检查点指向model.ckpt.data-00000-of-00001其模型动物园中提供的模型,但eval.py不喜欢这样。

checkpoint
   model_checkpoint_path: "model.ckpt.data-00000-of-00001"
Run Code Online (Sandbox Code Playgroud)

我曾考虑过对经过预训练的人进行短暂的训练,然后对其进行评估……但是我不确定这是否能为我提供正确的指标。

抱歉,这是一个基本问题-我刚开始使用Tensorflow,并想验证我是否得到了正确的信息。将不胜感激任何指针!

编辑:

我根据乔纳森的回答做了一个检查点文件:

model_checkpoint_path: "model.ckpt"
all_model_checkpoint_paths: "model.ckpt"
Run Code Online (Sandbox Code Playgroud)

评估脚本所使用的内容,并使用COCO数据集进行评估。但是评估停止了,并说形状不匹配:

...
[[Node: save/Assign_19 = Assign[T=DT_FLOAT, _class=["loc:@BoxPredictor_4/ClassPredictor/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](BoxPredictor_4/ClassPredictor/weights, save/RestoreV2_19/_15)]]
2017-07-05 18:40:11.969641: W tensorflow/core/framework/op_kernel.cc:1158] Invalid argument: Assign requires shapes of both tensors to match. lhs shape= [1,1,256,486] rhs shape= [1,1,256,546]
[[Node: save/Assign_19 = Assign[T=DT_FLOAT, _class=["loc:@BoxPredictor_4/ClassPredictor/weights"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](BoxPredictor_4/ClassPredictor/weights, save/RestoreV2_19/_15)]]
2017-07-05 18:40:11.969725: W tensorflow/core/framework/op_kernel.cc:1158] 
...
Invalid argument: Assign requires shapes of both tensors to match. lhs shape= [1,1,256,486] rhs shape= [1,1,256,546]
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1,1,256,486] rhs shape= [1,1,256,546]
Run Code Online (Sandbox Code Playgroud)

是什么导致此形状不匹配?我该如何解决?

小智 4

您可以通过运行 eval.py 脚本来评估预训练模型。它将要求您指向一个配置文件(将位于目录中samples/configs)和一个检查点,为此您将提供一个表单路径.../.../model.ckpt(删除任何扩展名,例如.meta, 或.data-00000-of-00001)。

\n\n

您还必须在包含您想要评估的检查点的目录中创建一个名为“checkpoint”的文件。然后在该文件中写入以下两行:

\n\n
\n

model_checkpoint_path: \xe2\x80\x9cpath/to/model.ckpt"
\n all_model_checkpoint_paths: \xe2\x80\x9cpath/to/model.ckpt"

\n
\n\n

(您可以适当修改路径/到/)

\n\n

最后得到的数字是平均精度,使用 50% IOU 作为真阳性的截止阈值。这与模型动物园中报告的指标略有不同,模型动物园使用 COCO mAP 指标并对多个 IOU 值进行平均。

\n