zexupan/USEV

Main.py avDprnn

Closed this issue · 1 comments

In your main.py, there is from avDprnn import usev. However, there isn't a file or folder named as such, nor a package that can be installed. I thought the avDprnn might be just the network file, as the class usev is in that file, and the model called in main.py is model = usev(args.N, args.L, args.B, args.H, args.K, args.R,args.C) which matches the input to the usev class in networks. However, running the main.py using network in place of avDprnn (using from network import usev) gives me error like following:
File "/home/username/Project/Speaker_Extraction/multimodal/USEV-main/src/usev-train/main.py", line 37, in main
solver = Solver(args=args,
File "/home/username/Project/Speaker_Extraction/multimodal/USEV-main/src/usev-train/solver.py", line 31, in init
self._reset()
File "/home/username/Project/Speaker_Extraction/multimodal/USEV-main/src/usev-train/solver.py", line 53, in _reset
self.model.load_state_dict(pretrained_model)
File "/home/username/anaconda3/envs/usev4/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2153, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for usev:
Missing key(s) in state_dict:..........................................
Am I wrong in assuming the avDprnn was the network? If not, what could I be doing wrong?

  1. You are right about the network file.
  2. Regarding this error, I think maybe you only used a single GPU to train, but the pretrained model is a distributed model. Thus the pretrained model needs to be converted to single GPU to load. A sample code replacing line 50-52 in solver.py could be:

pretrained_model = torch.load('%smodel_dict_best.pt' % args.continue_from, map_location='cpu')['model']
state = model.state_dict()
for key in state.keys():
pretrain_key = 'module.' + key
# if pretrain_key in pretrained_model.keys():
state[key] = pretrained_model[pretrain_key]
model.load_state_dict(state)