How to get number of classes from .pth file without any model information in Python?
I have a .pth file and there is no model information available. How can I know the number of final output classes in .pth file.
For visualization, I can use Netron to see the number of classes. But, how can I get the same output number in Python.

You can load the checkpoint and inspect the shape of the weights of the last layer. Depending if the last layer has two weights (kernel and bias), you will have to inspect both.
I provide you with an example on how to inspect the last weight.
import torch

checkpoint = torch.load('_.pt')

last_key = list(checkpoint)[-1]
print(checkpoint[last_key].size())

