Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

training result #9

Open
xyxiaoAk opened this issue Dec 25, 2023 · 2 comments
Open

training result #9

xyxiaoAk opened this issue Dec 25, 2023 · 2 comments

Comments

@xyxiaoAk
Copy link

Hi, I used the training code you provided for training, but didn't find the result of the training which is a similar file like the harmonizer.pth you provided. May I know where this file is stored after training? Or what part of the code needs to be changed to get this file?

@xyxiaoAk
Copy link
Author

xyxiaoAk commented Dec 25, 2023

And I transform the final checkpoint_60.ckpt to checkpoint_60.pth only using the "model" parameter in checkpoint_60.ckpt,but it reports errors when testing :" RuntimeError: Error(s) in loading state_dict for Harmonizer: Missing key(s) in state_dict: "backbone._blocks.0._depthwise_conv.weight",..."

Thanks ahead for your help!
And My code is as follows

import torch

# 指定 checkpoint 文件的路径
checkpoint_path = 'checkpoint_60.ckpt'

checkpoint = torch.load(checkpoint_path)
# 提取模型的参数
model_state_dict = checkpoint['model']

torch.save(model_state_dict, "checkpoint_60.pth")

@wangyuze18
Copy link

just convert it to proper format like this

state_dict = torch.load('checkpoint_60.ckpt')['model']
new_state_dict = {}
for key in state_dict:
    # 去掉 module.model 前缀
    if key.startswith('module.model'):
        new_key = key.replace('module.model.', '')  # 注意这里要加上点以确保路径正确
        new_state_dict[new_key] = state_dict[key]
    else:
        new_state_dict[key] = state_dict[key]

model.load_state_dict(new_state_dict)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants