首页 > 解决方案 > 如何在 Tensorflow 对象检测 API 上评估我训练有素的模型?

问题描述

我使用 Tensorflow 的对象检测 API 训练了一个模型,我在 Tensorboard 上看到了评估结果。

现在我需要使用新的测试数据运行另一个仅评估运行。

我确实搜索了文档和其他 stackoverflow 问题,但我找不到正确的方法,只有旧模式,这对我不起作用。

这样做的正确方法是什么?

标签: tensorflowevaluationobject-detection-api

解决方案


您还可以使用model_main.py来评估您的模型。

如果您想在验证数据上评估您的模型,您应该使用:

python models/research/object_detection/model_main.py --pipeline_config_path=/path/to/pipeline_file --model_dir=/path/to/output_results --checkpoint_dir=/path/to/directory_holding_checkpoint --run_once=True

如果你想在训练数据上评估你的模型,你应该将 'eval_training_data' 设置为 True,即:

python models/research/object_detection/model_main.py --pipeline_config_path=/path/to/pipeline_file --model_dir=/path/to/output_results --eval_training_data=True --checkpoint_dir=/path/to/directory_holding_checkpoint --run_once=True

我还添加了注释以澄清以前的一些选项:

--pipeline_config_path:用于训练检测模型的“pipeline.config”文件的路径。此文件应包含您要评估的 TFRecords 文件(训练和测试文件)的路径,即:

    ...
    train_input_reader: {
        tf_record_input_reader {
                #path to the training TFRecord
                input_path: "/path/to/train.record"
        }
        #path to the label map 
        label_map_path: "/path/to/label_map.pbtxt"
    }
    ...
    eval_input_reader: {
        tf_record_input_reader {
            #path to the testing TFRecord
            input_path: "/path/to/test.record"
        }
        #path to the label map 
        label_map_path: "/path/to/label_map.pbtxt"
    }
    ...

--model_dir:将写入结果指标的输出目录,特别是 tensorboard 可以读取的“events.*”文件。

--checkpoint_dir:保存检查点的目录。这是在训练过程中或在使用“export_inference_graph.py”导出后写入检查点文件(“model.ckpt.*”)的模型目录。

--run_once : True 只运行一轮评估。


推荐阅读