【发布时间】:2019-08-22 15:51:50
【问题描述】:
我想使用 Google Cloud 在新的测试集上评估经过自定义训练的 Tensorflow 对象检测模型。
我从以下位置获得了初始检查点: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
我知道 Tensorflow 对象检测 API 允许我通过以下方式同时运行训练和评估:
https://github.com/tensorflow/models/blob/master/research/object_detection/model_main.py
要开始这样的工作,我提交以下 ml-engine 工作:
gcloud ml-engine jobs submit training [JOBNAME]
--runtime-version 1.9
--job-dir=gs://path_to_bucket/model-dir
--packages dist/object_detection-
0.1.tar.gz,slim/dist/slim-0.1.tar.gz,pycocotools-2.0.tar.gz
--module-name object_detection.model_main
--region us-central1
--config object_detection/samples/cloud/cloud.yml
--
--model_dir=gs://path_to_bucket/model_dir
--pipeline_config_path=gs://path_to_bucket/data/model.config
但是,在我成功迁移训练了一个模型后,我想在一个新的测试数据集上使用计算性能指标,例如 COCO mAP(http://cocodataset.org/#detection-eval) 或 PASCAL mAP (http://host.robots.ox.ac.uk/pascal/VOC/pubs/everingham10.pdf)以前使用过(无论是在训练期间还是在评估期间)。
我已经看到,model_main.py 中有可能的标志:
flags.DEFINE_string(
'checkpoint_dir', None, 'Path to directory holding a checkpoint. If '
'`checkpoint_dir` is provided, this binary operates in eval-only
mode, '
'writing resulting metrics to `model_dir`.')
但我不知道这是否真的暗示 model_main.py 可以在独占评估模式下运行?如果是,我应该如何提交 ML-Engine 作业?
另外,Tensorflow API 中是否有任何函数允许我基于 COCO 和/或 Pascal mAP 评估现有输出字典(包含边界框、类标签、分数)?如果有,我可以轻松地在本地读取 Tensorflow 记录文件,运行推理,然后评估输出字典。
我知道如何获取评估数据集的这些指标,该数据集在训练期间在 model_main.py 中进行评估。但是,根据我的理解,我仍然应该报告新测试数据集的模型性能,因为我比较了多个模型并实施了一些超参数优化,因此我不应该报告评估数据集,对吗?笼统地说:我真的无法理解为什么要从单独的训练和评估(就像在遗留代码中一样)切换到组合的训练和评估脚本?
编辑: 我找到了两个相关的帖子。但是我认为提供的答案并不完整:
how to check both training/eval performances in tensorflow object_detection
How to evaluate a pretrained model in Tensorflow object detection api
后者是在 TF 的对象检测 API 仍然有单独的评估和训练脚本时编写的。现在已经不是这样了。
非常感谢您的帮助。
【问题讨论】:
-
谢谢,我也在寻找只运行评估的功能。
标签: python tensorflow google-cloud-ml object-detection-api