pspnet-pytorch icon indicating copy to clipboard operation
pspnet-pytorch copied to clipboard

how to use pretrained models?

Open AI-liu opened this issue 7 years ago • 7 comments

AI-liu avatar Sep 21 '17 02:09 AI-liu

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.

cardwing avatar Feb 27 '18 02:02 cardwing

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

Primus-zhao avatar Sep 21 '18 07:09 Primus-zhao

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)

alialamiidrissi avatar Oct 26 '18 13:10 alialamiidrissi

are those pretrained weights obtained by training on ImageNet?

engharat avatar Nov 08 '18 11:11 engharat

@alialamiidrissi thanks for your solution, worked!

tsing90 avatar Mar 04 '19 11:03 tsing90

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

fasogbon avatar Jun 25 '19 18:06 fasogbon

@alialamiidrissi thank you for your solution. It woked!

gaohuiluo avatar Jun 02 '20 13:06 gaohuiluo