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

Unable to load pre-trained model checkpoint with TensorFlow Object Detection API

类似这个问题:

(这个解决方案对我不起作用)

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

我只是改变了 num 类 和调优、训练和评估的路径。

与:

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 mag
ic number): perhaps your file is in a different file format and you need to use a different restore operator?

我目前正在使用绝对路径,因为它最简单,但如果有问题,我可以重新组织我的项目结构。

Checkpoint Folder

官方文档来自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

Source

只需将反斜杠更改为正斜杠,因为您在 windows