Deep-Learning icon indicating copy to clipboard operation
Deep-Learning copied to clipboard

Issue with running infer file

Open raws84 opened this issue 1 year ago • 1 comments

Hi Moein, It looks like there is some difference in keys in the saved model and model architecture. While using the infer file, I am getting the following error. Any thoughts on how to fix this?

model initialized with norm initialization model initialized with norm initialization RuntimeError Traceback (most recent call last) in <cell line: 11>() 9 saved_model_dict = torch.load('final_model_weights.pt', map_location=device) 10 model = MainModel() ---> 11 model.load_state_dict(saved_model_dict) 12 13 # Load the black and white image and resize it

/usr/local/lib/python3.9/dist-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict) 2039 2040 if len(error_msgs) > 0: -> 2041 raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( 2042 self.class.name, "\n\t".join(error_msgs))) 2043 return _IncompatibleKeys(missing_keys, unexpected_keys)

RuntimeError: Error(s) in loading state_dict for MainModel: Missing key(s) in state_dict: "net_G.model.model.0.weight",

raws84 avatar Apr 20 '23 05:04 raws84

Initialize the ResNet weights as well. You have to train and save the weights by yourself.

soumyamindfire avatar Jun 11 '24 12:06 soumyamindfire