GeneFacePlusPlus icon indicating copy to clipboard operation
GeneFacePlusPlus copied to clipboard

我遇到这个问题,加载模型的权重和代码中定义的网络结构不匹配,请问怎么改?

Open my369369 opened this issue 1 year ago • 12 comments
trafficstars

/data/AI_big_model/GeneFacePlusPlus-main/GeneFacePlusPlus-main/tasks/radnerfs/dataset_utils.py:266: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor). self.lm68s = torch.tensor(self.lm2ds[:, index_lm68_from_lm478, :]) val: Smooth head trajectory (rotation and translation) with a window size of 7 | Copied codes to checkpoints/motion2video_nerf/may_head/codes/20240311141348. Traceback (most recent call last): File "/data/AI_big_model/GeneFacePlusPlus-main/GeneFacePlusPlus-main/utils/commons/trainer.py", line 150, in fit self.run_single_process(self.task) File "/data/AI_big_model/GeneFacePlusPlus-main/GeneFacePlusPlus-main/utils/commons/trainer.py", line 205, in run_single_process self.restore_weights(checkpoint) File "/data/AI_big_model/GeneFacePlusPlus-main/GeneFacePlusPlus-main/utils/commons/trainer.py", line 467, in restore_weights getattr(task_ref, k).load_state_dict(v, strict=True) File "/data/anaconda3/envs/geneface/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2041, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for RADNeRFwithSR: size mismatch for blink_encoder.1.weight: copying a param with shape torch.Size([8, 32]) from checkpoint, the shape in current model is torch.Size([2, 32]). size mismatch for blink_encoder.1.bias: copying a param with shape torch.Size([8]) from checkpoint, the shape in current model is torch.Size([2]). Terminated

my369369 avatar Mar 11 '24 06:03 my369369

你修改了config文件,但是两个数值没对上吧

Net-Maker avatar Mar 11 '24 09:03 Net-Maker

我只修改了了video_id,其他的没有改

my369369 avatar Mar 11 '24 13:03 my369369

依然报这个错误

my369369 avatar Mar 11 '24 13:03 my369369

这个问题看起来像是你把blink_embedding_dim改了,head的dim和torso的dim不一致导致的

Net-Maker avatar Mar 14 '24 02:03 Net-Maker

将 lm3d_radnerf_torso_sr.yaml中的eye_blink_dim改为2就可以了

tailangjun avatar Mar 16 '24 06:03 tailangjun

将 lm3d_radnerf_torso_sr.yaml中的eye_blink_dim改为2就可以了

very helpful, thx

zhuyang2356 avatar Mar 18 '24 15:03 zhuyang2356

作者修改了参数

karl-tao-zhang avatar Mar 19 '24 12:03 karl-tao-zhang

我这边改了参数还是不行,报错是这样的

Traceback (most recent call last): File "/root/GeneFacePlusPlus/./utils/commons/trainer.py", line 150, in fit self.run_single_process(self.task) File "/root/GeneFacePlusPlus/./utils/commons/trainer.py", line 205, in run_single_process self.restore_weights(checkpoint) File "/root/GeneFacePlusPlus/./utils/commons/trainer.py", line 467, in restore_weights getattr(task_ref, k).load_state_dict(v, strict=True) File "/root/miniconda3/envs/geneface/lib/python3.9/site-packages/torch/nn/modules/module.py", line 2041, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for RADNeRFwithSR: size mismatch for blink_encoder.1.weight: copying a param with shape torch.Size([8, 32]) from checkpoint, the shape in current model is torch.Size([4, 32]). size mismatch for blink_encoder.1.bias: copying a param with shape torch.Size([8]) from checkpoint, the shape in current model is torch.Size([4]).

AspadaX avatar Mar 27 '24 07:03 AspadaX

要把checkpoints/motion2nerf/{video}/lm3d_radnerf_torso_sr.yaml里面的一起改掉

jinqiupeter avatar Mar 27 '24 08:03 jinqiupeter

image 将这个目录下的lm3d_radnerf_sr.yaml和lm3d_radnerf_torso_sr.yaml中的eye_blink_dim改一致

my369369 avatar Mar 27 '24 08:03 my369369

Shit, I had just figured this out. I was so dumb that I revised the file in a separate clone so that my current clone does not work no matter how hard I tried...

AspadaX avatar Mar 28 '24 01:03 AspadaX

Here, I changed eye_blink_dim to 8

marsjin avatar Apr 12 '24 07:04 marsjin