Skip to content

Utilizing resnet_50.pth for 3D Feature Map Extraction #83

@aeinkoupaei

Description

@aeinkoupaei

Hi, I want to use resnet_50.pth pre-trained encoder to extract 3D feature maps from medical images. Is the following method correct? It seems strange that the parameters of width, height, depth and number of channels can be adjusted manually. Isn't it the case that the resnet_50.pth pre-trained model is trained with a specific architecture, length, width, height, and channel? Therefore, shouldn't the input of the trained model for extracting 3D feature maps have the same dimensions as inputs of the model in the training phase?

resnet50 = resnet50(
sample_input_D=32,
sample_input_H=256,
sample_input_W=256,
shortcut_type='B',
no_cuda=True,
num_seg_classes=1
)
pretrain = torch.load("pretrain/resnet_50.pth") # Load the weights from the pretrained file
pretrained_dict = pretrain['state_dict']
new_state_dict = OrderedDict()
for k, v in pretrained_dict.items():
name = k[7:] # Remove 'module.'
new_state_dict[name] = v
resnet10.load_state_dict(new_state_dict, strict=False)

A_img_feature_map = resnet50(A_img)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions