Open Kurumi233 opened 4 years ago
hello,sir.Extracting the model tar diretory has an error ,do you have the same question?
hello,sir.Extracting the model tar diretory has an error ,do you have the same question?
No, I just have an error I metioned above.
Are you extracting the tar file to load the model? Just torch.load('***.tar') will be ok.
thank you,sir.I have solve my question from yours.maybe ,your question can be handled by this: model = ResNet(ECABottleneck, [3, 4, 6, 3], num_classes=num_classes, k_size=k_size) if pretrained:
pretrained_model=torch.load('/home/lgl/.cache/torch/checkpoints/eca_resnet50_k3557.pth.tar')
state = model.state_dict()
for key in state.keys():
if key in pretrained_model.keys():
state[key] = pretrained_model[key]
model.load_state_dict(state)
thank you,sir.I have solve my question from yours.maybe ,your question can be handled by this: model = ResNet(ECABottleneck, [3, 4, 6, 3], num_classes=num_classes, k_size=k_size) if pretrained:
pretrained_model = model_zoo.load_url(model_urls['resnet50'])
pretrained_model=torch.load('/home/lgl/.cache/torch/checkpoints/eca_resnet50_k3557.pth.tar') state = model.state_dict() for key in state.keys(): if key in pretrained_model.keys(): state[key] = pretrained_model[key] model.load_state_dict(state)
Yes, thanks. I just want to use a totally pretrained model, so I have to change the model file.
@BangguWu @amdslgl @Kurumi233 Hello! Thank you for your repo and answers! Your method helps me solve the problem that the parameters do not match the model.But when ECA_ Mobilenetv2 pretraining was loaded into my model, during the training of my model, it was found that MIOU was only 3.5%, and almost no growth. Why is this? PS:Part of my mobilnet network uses serial atrous convolution and ECA block in your code.
When I load the pre-trained model, some paramters are not match, and I change 96 in following code to 64, it fixed.
Is it a bug of model or paramters ?
https://github.com/BangguWu/ECANet/blob/cf8a4c8b3d49b27c12e98ceb930d0f7db6c2460a/models/eca_mobilenetv2.py#L77