首页 > 解决方案 > 我可以在 pipeline.config 中为 TF2 对象检测 API 定义多个 metrics_set

问题描述

我一直想知道是否可以为一个模型定义多个 metrics_set。我阅读了源代码,阅读了大量文章,甚至学习了 proto2 语法以查看是否可以根据需要修改代码。但无法得到任何结果。(另外 .config 文件看起来不像是用 proto2 编写的)。

有什么建议么?

标签: tensorflowtensorflow2.0object-detectionobject-detection-api

解决方案


TensorFlow Object Detection API 目前支持三种评估协议,可以在 EvalConfig 中通过将 metrics_set 设置为相应的值来进行配置。

  1. coco_detection_metrics
  2. pascal_voc_detection_metrics
  3. oid_V2_detection_metrics

这意味着,蝙蝠右侧tensorflow 2.X支持 3 个评估指标及其细微变化。Tensorflow 在项目中提到了它们,但您必须下载它们并自己编译 protobuf 并将其放在您的 python 项目下。提到了 tensorflow 支持和已经可用的评估指标列表。

要在您的项目中安装coco_detection_metrics和使用它们,请执行以下操作:

git clone https://github.com/cocodataset/cocoapi.git
cd coco/PythonAPI && make

如果我可以为一个模型定义多个metrics_set?

改变pipeline.config不会帮助你做到这一点。评估实际上是一个您必须运行的单独过程。pipeline.config在我看来,在培训进行期间,您绝对可以在指向单独文件的培训目录上运行多个评估。

以您的配置文件为例。

#file coco.config
eval_config: {
  metrics_set: "coco_detection_metrics"
  use_moving_averages: false
  batch_size: 1
  num_visualizations: 10
  max_num_boxes_to_visualize: 5
  visualize_groundtruth_boxes: true
  eval_interval_secs: 30
}
... other stuff
--
#file pascal.config
eval_config: {
  metrics_set: "pascal_voc_detection_metrics"
  use_moving_averages: false
  batch_size: 1
  num_visualizations: 10
  max_num_boxes_to_visualize: 5
  visualize_groundtruth_boxes: true
  eval_interval_secs: 30
}
.... other stuff

然后同时运行两个评估。在两个不同的端口中运行一个单独的张量板来查看每个端口。

!python object_detection/model_main_tf2.py \
--pipeline_config_path={pipeline_file} \
--model_dir='path/to/training/dir' \
--alsologtostderr \
--checkpoint_dir='path/to/training/checkpoint' 

推荐阅读