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

how to use pretrained models? #3

Open
AI-liu opened this issue Sep 21, 2017 · 7 comments
Open

how to use pretrained models? #3

AI-liu opened this issue Sep 21, 2017 · 7 comments

Comments

@AI-liu
Copy link

AI-liu commented Sep 21, 2017

No description provided.

@cardwing
Copy link

In extractors.py, you can find the pre-trained weights in the following URLs:
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth',
'resnet50': 'https://download.pytorch.org/models/resnet50-19c8e357.pth',
'resnet101': 'https://download.pytorch.org/models/resnet101-5d3b4d8f.pth',
'resnet152': 'https://download.pytorch.org/models/resnet152-b121ed2d.pth',
}
Hope this issue can be closed.

@Primus-zhao
Copy link

@cardwing when i use resnet pretrained model, it always give tips that lots of layers' weights not given

@alialamiidrissi
Copy link

alialamiidrissi commented Oct 26, 2018

I have the same problem, I get multiple errors when trying to load the pre-trained resnets. It seems that the checkpoint and the created model layers names and shapes don't match.

EDIT:
I solved the issue by changing the function 'load_weights_sequential' as follow:


def load_weights_sequential(target, source_state):
    model_to_load= {k: v for k, v in source_state.items() if k in target.state_dict().keys()}
    target.load_state_dict(model_to_load)

@engharat
Copy link

engharat commented Nov 8, 2018

are those pretrained weights obtained by training on ImageNet?

@tsing90
Copy link

tsing90 commented Mar 4, 2019

@alialamiidrissi thanks for your solution, worked!

@fasogbon
Copy link

Hello, does anybody have a trained model and/or test script to test the method? Thanks

@gaohuiluo
Copy link

@alialamiidrissi thank you for your solution. It woked!

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

8 participants