如何使用Tensorflow对象检测API继续训练对象检测模型? [英] How to continue training an object detection model using Tensorflow Object Detection API?
问题描述
我正在使用 Tensorflow对象检测API使用转移学习训练对象检测模型.具体来说,我正在使用 ssd_mobilenet_v1_fpn_coco从模型动物园中,并使用提供了示例管道,当然已用与我的培训以及评估tfrecords和标签的实际链接替换了占位符.
I'm using Tensorflow Object Detection API to train an object detection model using transfer learning. Specifically, I'm using ssd_mobilenet_v1_fpn_coco from the model zoo, and using the sample pipeline provided, having of course replaced the placeholders with actual links to my training and eval tfrecords and labels.
我能够使用上述管道成功地在约5000张图像(以及相应的边界框)上训练模型(如果愿意的话,我主要是在TPU上使用Google的ML引擎).
I was able able to successfully train a model on my ~5000 images (and corresponding bounding boxes) using the above pipeline (I'm mainly using Google's ML Engine on TPU, if revelant).
现在,我准备了约2000张图像,并希望继续用这些新图像训练模型,而无需从头开始(训练初始模型花了大约6个小时的TPU时间).我该怎么办?
Now, I prepared an additional ~2000 images, and would like continue training my model with those new images, without restarting from scratch (training the initial model took ~6h of TPU time). How can I do that?
推荐答案
您有两个选择,都需要更改新版本 train_input_reader
的 input_path
数据集:
You have two options, in both you need to change the input_path
of the train_input_reader
of your new dataset:
- 在训练配置中指定要微调的检查点时,请指定训练模型的检查点
train_config{
fine_tune_checkpoint: <path_to_your_checkpoint>
fine_tune_checkpoint_type: "detection"
load_all_detection_checkpoint_vars: true
}
- 只需继续使用与先前模型相同的配置(除了
train_input_reader
)和相同的model_dir
.这样,API将创建一个图形并检查model_dir
中是否已经存在一个检查点并适合该图形.如果是这样,它将恢复并继续训练.
- Simply keep using the same configuration (except the
train_input_reader
) with the samemodel_dir
of your previous model. That way, the API will create a graph and will check whether a checkpoint already exists inmodel_dir
and fits the graph. If so - it will restore it and continue training it.
fine_tune_checkpoint_type先前被错误地设置为true,而通常应为检测"或分类",在这种情况下应为检测".感谢克里希(Krish)的注意.
fine_tune_checkpoint_type was previously set as true by mistake, while it should be "detection" or "classification" in general, and "detection" in this specific case. Thanks Krish for noticing.
这篇关于如何使用Tensorflow对象检测API继续训练对象检测模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!