health_multimodal.image.model.resnet

Functions

resnet18([pretrained, progress])

ResNet-18 model from “Deep Residual Learning for Image Recognition”.

resnet50([pretrained, progress])

ResNet-50 model from “Deep Residual Learning for Image Recognition”.

Classes

ResNetHIML(**kwargs)

Wrapper class of the original torchvision ResNet model.

class health_multimodal.image.model.resnet.ResNetHIML(**kwargs)[source]

Wrapper class of the original torchvision ResNet model.

The forward function is updated to return the penultimate layer activations, which are required to obtain image patch embeddings.

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward(x, return_intermediate_layers=False)[source]

ResNetHIML forward pass. Optionally returns intermediate layers using the return_intermediate_layers argument.

Parameters

return_intermediate_layers (bool) – If True, return layers x0-x4 as a tuple, otherwise return x4 only.

Return type

Union[Tensor, Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]]

health_multimodal.image.model.resnet.resnet18(pretrained=False, progress=True, **kwargs)[source]

ResNet-18 model from “Deep Residual Learning for Image Recognition”.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet.

  • progress (bool) – If True, displays a progress bar of the download to stderr.

Return type

ResNetHIML

health_multimodal.image.model.resnet.resnet50(pretrained=False, progress=True, **kwargs)[source]

ResNet-50 model from “Deep Residual Learning for Image Recognition”.

Parameters
  • pretrained (bool) – If True, returns a model pre-trained on ImageNet

  • progress (bool) – If True, displays a progress bar of the download to stderr.

Return type

ResNetHIML