首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tensorflow object_detection保存和加载微调模型的正确方法

Tensorflow object_detection保存和加载微调模型的正确方法
EN

Stack Overflow用户
提问于 2020-12-27 05:53:00
回答 1查看 424关注 0票数 0

我正在使用colabs教程中的示例对模型进行微调,经过培训后,我希望使用以下方法保存模型并在本地计算机上加载:

代码语言:javascript
复制
ckpt_manager = tf.train.CheckpointManager(ckpt, directory="test_data/checkpoint/", max_to_keep=5)
...
...
print('Done fine-tuning!')

ckpt_manager.save()
print('Checkpoint saved!')

但是在我的本地计算机上恢复之后,使用检查点文件不会检测到任何对象(分数太低)。

我也试过了

代码语言:javascript
复制
tf.saved_model.save(detection_model, '/content/new_model/')

然后装上这个:

代码语言:javascript
复制
detection_model = tf.saved_model.load('/saved_model_20201226/')

input_tensor = tf.convert_to_tensor(image, dtype=tf.float32)
detections = detection_model(input_tensor)

告诉我以下错误: TypeError:'_UserObject‘对象不可调用

保存和加载优化模型的正确方法是什么?

编辑1: --它正在等待保存新的管道配置,在那之后终于起作用了!这是我的回答:

代码语言:javascript
复制
# Save new pipeline config
new_pipeline_proto = config_util.create_pipeline_proto_from_configs(configs)
config_util.save_pipeline_config(new_pipeline_proto, '/content/new_config')
exported_ckpt = tf.compat.v2.train.Checkpoint(model=detection_model)
ckpt_manager = tf.train.CheckpointManager(
exported_ckpt, directory="test_data/checkpoint/", max_to_keep=5)
...
...
print('Done fine-tuning!')

ckpt_manager.save()
print('Checkpoint saved!')
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-27 08:55:58

它正在等待保存新的管道配置,在此之后,终于起作用了!这是我的回答:

代码语言:javascript
复制
# Save new pipeline config
new_pipeline_proto = config_util.create_pipeline_proto_from_configs(configs)
config_util.save_pipeline_config(new_pipeline_proto, '/content/new_config')

exported_ckpt = tf.compat.v2.train.Checkpoint(model=detection_model)
ckpt_manager = tf.train.CheckpointManager(
exported_ckpt, directory="test_data/checkpoint/", max_to_keep=5)
...
...
print('Done fine-tuning!')

ckpt_manager.save()
print('Checkpoint saved!')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65463236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档