Thank you Sir, but there is a doubt. Actually I am using the deeplabv3 library with resnet101 backbone. I have 2 classes, and I created a model and saved it as ‘segmodel.pth’ . and if i check the summary like the way you mentioned in the above comment by passing num_classes=2, I got the summary which is different from when I run model.eval().
In model.eval(), it shows the aux_classifier also i.e (FCN head), and in summary it is not showing that aux_classifier.
Moreover the output stride is 16 in summary , while in model.eval it is 8 (according to dilation rates =12,24,36).
and now I checked it like this following
model = deeplabv3_resnet101(num_classes=2)
model.load_state_dict(torch.load('segmodel.pth'))
summary(model, input_size=(batch_size,3,128,128))
and got the following error
RuntimeError Traceback (most recent call last)
<ipython-input-45-019b1f66b653> in <cell line: 8>()
6
7 model = deeplabv3_resnet101(num_classes=2)
----> 8 model.load_state_dict(torch.load('segmodel.pth'))
9 summary(model, input_size=(batch_size,3,128,128))
10
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict, assign)
2150
2151 if len(error_msgs) > 0:
-> 2152 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
2153 self.__class__.__name__, "\n\t".join(error_msgs)))
2154 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for DeepLabV3:
Unexpected key(s) in state_dict: "aux_classifier.0.weight", "aux_classifier.1.weight", "aux_classifier.1.bias", "aux_classifier.1.running_mean", "aux_classifier.1.running_var", "aux_classifier.1.num_batches_tracked", "aux_classifier.4.weight", "aux_classifier.4.bias".