How do you load a model from the mode Zoo (say: https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth)
and how do you forward with this model file?
How do you load a model from the mode Zoo (say: https://s3.amazonaws.com/pytorch/models/resnet18-5c106cde.pth)
and how do you forward with this model file?
To open that file (which is a collection of weights) you can use params = torch.load('resnet18-5c106cde.pth')
.
To get a ResNet-18, instead, you should use res18 = torchvision.models.resnet18(pretrained=True)
.
To forward a random image, you can define a FloatTensor
, encapsulate it into a Variable
and send it to the network.
x = torch.rand(1, 3, 224, 224)
xVar = torch.autograd.Variable(x)
res18(xVar)
-->
Variable containing:
-0.4374 -0.3994 -0.5249 ... -0.5333 1.4113 0.9452
[torch.FloatTensor of size 1x1000]
You can access the output vector by appending .data
to your output Variable
.
Let me know if it works.
Nice to see you two again