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

KeyError: 'base.conv1.weight' #16

Open
x1ng4me opened this issue Mar 25, 2020 · 3 comments
Open

KeyError: 'base.conv1.weight' #16

x1ng4me opened this issue Mar 25, 2020 · 3 comments

Comments

@x1ng4me
Copy link

x1ng4me commented Mar 25, 2020

Trying to run the code. Got the error

KeyError: 'base.conv1.weight' in backbone file.

Have any idea to solve this?

Thank you.

@HWNHJJ
Copy link

HWNHJJ commented May 14, 2020

多GPU训练保存的参数单GPU的环境无法直接用

@mojiayuan
Copy link

多GPU训练保存的参数单GPU的环境无法直接用
您好,这个解决不了吗

@DoranLyong
Copy link

As I can't use Baidu account, I downloaded the pretrained model from here.
Then, I got the same problem.

I found out that the pretrained model file has different layer names with this repository.

So, I fixed the code block a bit and it worked!

Go to .../model/backbones/resnet.py
and I changed def load_param(self, model_path) block like:

    def load_param(self, model_path):
        param_dict = torch.load(model_path)
        for i in param_dict:
            j = i.replace("base.","")
            if 'fc' in i:
                continue
            if j in self.state_dict().keys():
                self.state_dict()[j].copy_(param_dict[i])

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

4 participants