首页 > 解决方案 > 'ValueError: Image with id {} already added' 在 OpenImage 数据集上运行评估时

问题描述

我正在使用 Tensorflow 对象检测 API 来评估 OpenImageV5 数据集上的 SSD_mobilenet 模型。我使用了他们的模型 zoo中提供的 pretained 模型。对于管道配置,我使用的是此处ssd_mobilenet_v2_oid_v4提供的默认管道 () 。

当我使用以下命令运行评估时:

python object_detection/model_main.py --alsologtostderr --run_once --checkpoint_dir=/Path/TO/ssd_mobilenet_v2_oid_v4_2018_12_12/ --model_dir=eval/ --pipeline_config_path=PATH/TO/ssd_mobilenet_v2_oid_v4.config

我收到此错误:

2019-05-28 12:26:09.658946: W tensorflow/core/framework/op_kernel.cc:1306] Invalid argument: ValueError: Image with id 1407414044 already added.
Traceback (most recent call last):

  File "/bigSSD/tensorflow_model/v_env_tf_1.8/lib/python3.6/site-packages/tensorflow/python/ops/script_ops.py", line 157, in __call__
    ret = func(*args)

  File "/bigSSD/tensorflow_model/models/research/object_detection/utils/object_detection_evaluation.py", line 432, in update_op
    self.add_single_ground_truth_image_info(image_id, single_example_dict)

  File "/bigSSD/tensorflow_model/models/research/object_detection/utils/object_detection_evaluation.py", line 600, in add_single_ground_truth_image_info
    raise ValueError('Image with id {} already added.'.format(image_id))

ValueError: Image with id 1407414044 already added.

sample_1_of_n_examples从 10 更改为 100 和 1000 但仍然遇到相同的错误。

标签: pythonvalidationtensorflowneural-networkobject-detection-api

解决方案


对于 faster_rcnn_inception_resnet_v2_atrous_oid_v4.config 我改变了

eval_config 
{
  metrics_set: "open_images_V2_detection_metrics"
}

eval_config {
  metrics_set: "open_images_V2_detection_metrics"
  num_examples: 383 #correspond to my test images
}

然后使用以下命令使用 eval.py 运行评估:

python eval.py --logtostderr --checkpoint_dir=path/to/checkpoint --eval_dir=path/to/eval_dir --pipeline_config_path=path/to/pretrained_model.config

我的错误解决了。


推荐阅读