无法使用TensorFlow对象检测API加载预训练模型检查点

与这个问题类似:

在faster_rcnn_resnet50_coco模型中,model.ckpt在哪里可以找到?(这个解决方案对我不起作用)

我已经下载了ssd_resnet152_v1_fpn_1024x1024_coco17_tpu-8,打算将其作为起点。我使用了与该模型在TF模型动物园中关联的样本模型配置。

我只更改了类别数量以及调优、训练和评估的路径。

使用:

fine_tune_checkpoint: "C:\\Users\\Peter\\Desktop\\Adv-ML-Project\\models\\research\\object_detection\\test_data\\checkpoint\\model.ckpt"

我得到:

tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for C:\Users\Pierre\Desktop\Adv-ML-Project\models\research\object_detection\test_data\checkpoint\model.ckpt

使用:

fine_tune_checkpoint: "C:\\Users\\Peter\\Desktop\\Adv-ML-Project\\models\\research\\object_detection\\test_data\\checkpoint\\ckpt-0.*"

我得到:

tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file C:\Users\Pierre\Desktop\Adv-ML-Project\models\research\object_detection\test_data\checkpoint\ckpt-0.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

我目前使用绝对路径,因为这样最简单,但如果这是一个问题,我可以重新组织我的项目结构。

检查点文件夹

来自https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2_training_and_evaluation.md的官方文档说应该做类似以下的事情

fine_tune_checkpoint: a path prefix to the pre-existing checkpoint (ie:"/usr/home/username/checkpoint/model.ckpt-#####").

我在这里做错了什么吗?我使用以下命令运行(也来自文档):

python object_detection/model_main_tf2.py \    --pipeline_config_path="C:\\Users\Pierre\\Desktop\\Adv-ML-Project\\models\\my_model\\my_model.config" \    --model_dir="C:\\Users\\Pierre\\Desktop\\Adv-ML-Project\\models\\my_model\\training" \    --alsologtostderr

回答:

尝试在配置文件中将fine_tune_checkpoint路径更改为类似path_to_folder/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8/checkpoint/ckpt-0的路径

在你的训练命令中,设置model_dir标志只指向模型目录,不要包含training,类似于--model_dir=<path_to>/ssd_resnet152_v1_fpn_1024x1024_coco17_tpu-8

来源

将反斜杠更改为正斜杠,因为你在使用Windows

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注