vincent-thevenin / Realistic-Neural-Talking-Head-Models

My implementation of Few-Shot Adversarial Learning of Realistic Neural Talking Head Models (Egor Zakharov et al.).
GNU General Public License v3.0
828 stars 195 forks source link

save_disc caffe pretrained model convertion error. #64

Open sunwoo76 opened 3 years ago

sunwoo76 commented 3 years ago

When I run the last command to convert caffe model to pytorch model: "mmtomodel -f pytorch -in Pytorch_VGGFACE_IR.py -iw Pytorch_VGGFACE_IR.npy -o Pytorch_VGGFACE.pth", I met the following problem:

Traceback (most recent call last): File "/root/anaconda3/bin/mmtomodel", line 10, in sys.exit(_main()) File "/root/anaconda3/lib/python3.7/site-packages/mmdnn/conversion/_script/dump_code.py", line 79, in _main ret = dump_code(args.framework, args.inputNetwork, args.inputWeight, args.outputModel, args.dump_tag) File "/root/anaconda3/lib/python3.7/site-packages/mmdnn/conversion/_script/dump_code.py", line 32, in dump_code save_model(MainModel, network_filepath, weight_filepath, dump_filepath) File "/root/anaconda3/lib/python3.7/site-packages/mmdnn/conversion/pytorch/saver.py", line 5, in save_model model = MainModel.KitModel(weight_filepath) File "Pytorch_VGGFACE_IR.py", line 27, in init self.conv1_1 = self.__conv(2, name='conv1_1', in_channels=3, out_channels=64, kernel_size=(3, 3), stride=(1, 1), groups=1, bias=True) File "Pytorch_VGGFACE_IR.py", line 129, in _conv layer.state_dict()['bias'].copy(torch.from_numpy(__weights_dict[name]['bias'])) RuntimeError: output with shape [64] doesn't match the broadcast shape [1, 1, 1, 64]

Any ideas to solve this problem?

liangsen-zju commented 3 years ago

I have the same problem

chaopengz commented 3 years ago

I have the same problem

vinayak015 commented 2 years ago

change line 126 of Pytorch_VGGFACE_IR.py. Ref layer.state_dict()['bias'].copy_(torch.from_numpy(_weights_dict[name]['bias'])) -> layer.state_dict()['bias'].copy_(np.squeeze(torch.from_numpy(_weights_dict[name]['bias'])))