本文介绍了如何在 Tensorflow Object Detection API v2 中同时训练和评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 Tf2 对象检测 API 的每个检查点训练和评估模型.在文档中,他们建议先训练然后评估模型

I was wondering how can I train and evaluate the model at each checkpoint in Tf2 object detection API.In the documentation, they suggest to train and then evaluate the model

训练

python object_detection/model_main_tf2.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --alsologtostderr

评估

python object_detection/model_main_tf2.py \
    --pipeline_config_path=${PIPELINE_CONFIG_PATH} \
    --model_dir=${MODEL_DIR} \
    --checkpoint_dir=${CHECKPOINT_DIR} \
    --alsologtostderr

我想要的是进行培训,并在创建每个检查点(1000 步)后进行评估.我知道在 TF-1 对象检测 API 中,评估是每 1000 步自动完成的,我想在 TF-2 中复制什么

what I want is to do the training and after each checkpoint created (1000 step) have an evaluation done.I know that in TF-1 object detection API the evaluation is done automatically each 1000 step and that what I want to replicate in TF-2

推荐答案

根据 model_main_tf2.py,他们在每个 epoch 都留下了一个评估标志,但它仅适用于分布式训练:https://github.com/tensorflow/模型/blob/master/research/object_detection/model_main_tf2.py#L37-L38

Acoording to the model_main_tf2.py, they have left a flag for evaluation at each epoch but it is only available for distributed training:https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py#L37-L38

但是,我认为当他们通过包含评估数据添加一些标志时,他们很快就会提供它:https://github.com/tensorflow/模型/blob/master/research/object_detection/model_main_tf2.py#L39-L44

However, I think they are on the way making it available soon when they have add some flag by including evaluation_data:https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py#L39-L44

更多细节,你可以查看他们的训练函数此处,针对他们的训练工作流程进行了描述.你可以看到他们还没有实施评估:https://github.com/tensorflow/models/blob/master/research/object_detection/model_lib_v2.py#L419

For further detail, you can look in the train function of them here, which is described for their training workflow. You can see they havent implement yet the evaluation:https://github.com/tensorflow/models/blob/master/research/object_detection/model_lib_v2.py#L419

因此,您必须通过创建一个使用 lib here 使用他们创建的一些评估方法并将其附加到您的训练文件中以评估每个时期.或者你可以等 :D

Therefore, you have to work around by creating a new train_file that use the lib here with some evaluation method that has been created by them and attach to your training file to evaluate every epoch. Or you can wait :D

这篇关于如何在 Tensorflow Object Detection API v2 中同时训练和评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 16:35