How to extract features of an image from a trained model

You can use the torchvision.models package, where you have functions for constructing various vision models, with an option of using pretrained weights. This:

torchvision.models.resnet18(pretrained=True)

will give you a nn.Module with downloaded weights.

7 Likes