pytorch_classifiers icon indicating copy to clipboard operation
pytorch_classifiers copied to clipboard

Can not load models to predict

Open KennyTC opened this issue 3 years ago • 0 comments

image

I was able to run Makefile.train to train, and save some models to the Models/ folder. But when I run Makefile.predict to load those models to test, the errors happened. The errors are due to this code in tars_predict.py. I set --used_dataparallel = False for both training and testing.

if args.used_dataparallel: new_state_dict = OrderedDict() for k, v in state_dict.items(): name = k[7:] # remove module. new_state_dict[name] = v print("[Loading Weights to the Model]") model_conv.load_state_dict(new_state_dict) print("go to here without problems") if not args.used_dataparallel: model_conv = nn.DataParallel(model_conv, device_ids=[0, 1, 2]) model_conv.load_state_dict(state_dict)

KennyTC avatar May 26 '21 02:05 KennyTC