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

pretrained 3d resnet #2836

Closed
JianJuly opened this issue Aug 25, 2021 · 5 comments
Closed

pretrained 3d resnet #2836

JianJuly opened this issue Aug 25, 2021 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@JianJuly
Copy link

Describe the bug
i intend to use pretrained resnet50 for feature extraction.
so first i tried the following codes

from monai.networks import nets
model = nets.resnet50(pretrained=True)

It raises NotImplementedError: Currently not implemented, see comments in source code

then i manually download the pretrained weights from https://github.com/Tencent/MedicalNet, and load it.
Yet it raises size mismatch for conv1.weight: copying a param with shape torch.Size([64, 1, 7, 7, 7]) from checkpoint, the shape in current model is torch.Size([64, 3, 7, 7, 7]).

I found that the first conv of resnet50 we import here is of shape 3×7×7×7, while it of pretrained weights if 1×7×7×7.
How can i address it?

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Install '....'
  3. Run commands '....'

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

Ensuring you use the relevant python executable, please paste the output of:

python -c 'import monai; monai.config.print_debug_info()'

Additional context
Add any other context about the problem here.

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 25, 2021

Hi @JianJuly ,

Thanks for your interest and experiments here.
I think to use the pretrained weights, maybe you need to set your input channel of resnet50 to 1 channel:

resnet50(..., n_input_channels=1)

Add @yiheng-wang-nv for further discussion.

Thanks.

@Nic-Ma Nic-Ma added the question Further information is requested label Aug 25, 2021
@JianJuly
Copy link
Author

@Nic-Ma Thank you for your quick reply. Another question is when will model = nets.resnet50(pretrained=True) accessible? or is there any easier way to use pretrained resnet (on 23 medical datasets) ?

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 25, 2021

Hi @JianJuly ,

I think it's still under discussion, we plan to provide some model zoo features in the short future.
@yiheng-wang-nv is there any easier way to use pretrained resnet (on 23 medical datasets)?

Thanks.

@wyli
Copy link
Contributor

wyli commented Aug 25, 2021

this becomes a duplicate of Project-MONAI/model-zoo#48, I'm closing this for now.

@wyli wyli closed this as completed Aug 25, 2021
@Borda
Copy link
Contributor

Borda commented Aug 26, 2021

I have tried to work with the referred weights but getting a compatibility issue: Project-MONAI/model-zoo#48

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

No branches or pull requests

5 participants