Could you please guide me how to use an HourGlass Network here that is pretrained on human pose instead of this ResNet18?
num_classes = 4 * 2 #4 coordinates X and Y flattened --> 4 of 2D keypoints or landmarks
self.model_name = 'resnet18'
self.model = models.resnet18()
self.model.fc = nn.Linear(self.model.fc.in_features, num_classes)
def forward(self, x):
x = x.float()
out = self.model(x)
For example, I found this Stacked Hourglass code for facial landmark detection which is a similar problem. How can I use it in my own PyTorch code such as I am calling models.resnet18()? Also, are there more standard implementations of Stacked hourglass network since it is a pretty much famous network (or any other baseline for human pose estimation with pretraining enabled)?
You just need to instantiate the desired model for instance self.model = HourGlass(args). Also, you need to load weights and state dict which you can find it here. (note that do not set model in eval mode)
the author replaces last linear layer to match their desired number of output classes. In your case, you need to find model definition (you can use this thread), and the change the appropriate layer based on the model definition.
Unfortunately I don’t know any implemenation of HourGlass.