问题总结:当我按照文档中的指南操作时,tensorflow自定义对象检测器从未开始微调。它也没有抛出任何异常。
我所做的: 我已经安装了对象检测器API,并根据文档成功运行了一个测试。
然后,我按照这里的指南训练了一个自定义对象检测器算法,包括修改pipeline.config文件。按照指南,我运行了
model_main_tf2.py --model_dir=<path1> --pipeline_config_path=<path2> --alsologtostderr
其中path1和path2是类似于以下路径的路径
D:/COCO/models/workspace/duck-demo/pre-trained-models/efficientdet_d1_coco17_tpu-32/pipeline.config
输出如下所示。输出包括许多警告,这些都是指南中预期的输出。然而,预期是在此之后开始训练。但它只是返回,没有错误也没有进行训练。这里似乎有什么问题?
输出:
...WARNING:tensorflow:Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.gammaW0326 09:24:46.180965 16300 util.py:160] Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.gammaWARNING:tensorflow:Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.betaW0326 09:24:46.180965 16300 util.py:160] Unresolved object in checkpoint: (root).model._feature_extractor._bifpn_stage.node_input_blocks.7.0.1.1.beta...WARNING:tensorflow:A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/guide/checkpoint#loading_mechanics for details.W0326 09:24:46.181965 16300 util.py:168] A checkpoint was restored (e.g. tf.train.Checkpoint.restore or tf.keras.Model.load_weights) but not all checkpointed values were used. See above for specific issues. Use expect_partial() on the load status object, e.g. tf.train.Checkpoint.restore(...).expect_partial(), to silence these warnings, or use assert_consumed() to make the check explicit. See https://www.tensorflow.org/guide/checkpoint#loading_mechanics for details.
回答:
有一个GitHub问题在这里,讨论了许多可能的解决方案,适用于不同类型的TensorFlow 2模型来解决您的问题。其中一个解决方案很有可能对您有帮助。
作为一个经验法则,在实际开始训练任何东西之前,运行命令python object_detection/builders/model_builder_tf2_test.py
来测试您的安装是个好主意,这样可以尽早诊断出任何可能的问题