zhanglonghao1992 / One-Shot_Free-View_Neural_Talking_Head_Synthesis

Pytorch implementation of paper "One-Shot Free-View Neural Talking-Head Synthesis for Video Conferencing"
Other
797 stars 143 forks source link

TypeError: load() missing 1 required positional argument: 'Loader' #35

Open Liangtian96 opened 2 years ago

Liangtian96 commented 2 years ago

大佬您好!我在用新的代码跑demo的时候报了下面这个错,旧的config文件夹下vox-256.yaml和从百度网盘中新下载的vox-256.yaml都试过了,还是报错,请问您知道应该如何解决吗?谢谢! One-Shot_Free-View_Neural_Talking_Head_Synthesis-main$ python demo.py --config config/vox-256.yaml --checkpoint 15kp-ep119.pth/archive/data.pkl --source_image SourceAndDriving/source.jpg --driving_video SourceAndDriving/driving.mp4 --relative --adapt_scale --find_best_frame Traceback (most recent call last): File "demo.py", line 287, in generator, kp_detector, he_estimator = load_checkpoints(config_path=opt.config, checkpoint_path=opt.checkpoint, gen=opt.gen, cpu=opt.cpu) File "demo.py", line 28, in load_checkpoints config = yaml.load(f) TypeError: load() missing 1 required positional argument: 'Loader'

Liangtian96 commented 2 years ago

已解决,附上网上收到的答案 YAML 5.1版本后弃用了yaml.load(file)这个用法,因为觉得很不安全,5.1版本之后就修改了需要指定Loader,通过默认加载​​器(FullLoader)禁止执行任意函数,该load函数也变得更加安全 把报错的load函数改成yaml.load(f,Loader=yaml.FullLoader)就可以了

zhanglonghao1992 commented 2 years ago

@Liangtian96 OK~

Liangtian96 commented 2 years ago

@zhanglonghao1992 大佬,在加载模型的时候遇到了下面这个问题,python版本和pytorch版本都是按照你的readme的版本装的,请问应该如何解决呢?另外百度网盘下的15kp-ep119.pth.tar解压后是15kp-ep119.pth命名的文件夹,而不是.pth文件,我选的模型是这个文件夹中的.pkl文件,对吗? One-Shot_Free-View_Neural_Talking_Head_Synthesis-main]$ python demo.py --config config/vox-256.yaml --checkpoint 15kp-ep119.pth/archive/data.pkl --source_image SourceAndDriving/source.jpg --driving_video SourceAndDriving/driving.mp4 --relative --adapt_scale --find_best_frame Traceback (most recent call last): File "demo.py", line 287, in generator, kp_detector, he_estimator = load_checkpoints(config_path=opt.config, checkpoint_path=opt.checkpoint, gen=opt.gen, cpu=opt.cpu) File "demo.py", line 53, in load_checkpoints checkpoint = torch.load(checkpoint_path) File "/home/lt/anaconda3/envs/Free-View_Neural_Talking_Head_Synthesis/lib/python3.6/site-packages/torch/serialization.py", line 595, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/lt/anaconda3/envs/Free-View_Neural_Talking_Head_Synthesis/lib/python3.6/site-packages/torch/serialization.py", line 764, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: A load persistent id instruction was encountered, but no persistent_load function was specified.

zhanglonghao1992 commented 2 years ago

@Liangtian96 你用的这个config和checkpoint是老的beta version。建议下新的config和checkpoint。如果要跑beta version记得把demo.py里的get_rotation_matrix()函数注释换掉,然后--gen参数选择original。

Liangtian96 commented 2 years ago

@zhanglonghao1992 大佬,我下了MF中的新模型和配置文件,但是运行的时候还是报同一个错误。我python装的3.6.3,pytorch装的1.7.0,后来看了网上的博客也升级过到1.7.1,但是都没有解决这个问题。 One-Shot_Free-View_Neural_Talking_Head_Synthesis-main]$ python demo.py --config config/vox-256-spade.yaml --checkpoint 15kp-ep119.pth/newModel/00000189-checkpoint.pth/archive/data.pkl --source_image SourceAndDriving/source.jpg --driving_video SourceAndDriving/driving.mp4 --relative --adapt_scale --find_best_frame --cpu Traceback (most recent call last): File "demo.py", line 287, in generator, kp_detector, he_estimator = load_checkpoints(config_path=opt.config, checkpoint_path=opt.checkpoint, gen=opt.gen, cpu=opt.cpu) File "demo.py", line 51, in load_checkpoints checkpoint = torch.load(checkpoint_path, map_location=torch.device('cpu')) File "/home/lt/anaconda3/envs/Free-View_Neural_Talking_Head_Synthesis/lib/python3.6/site-packages/torch/serialization.py", line 595, in load return _legacy_load(opened_file, map_location, pickle_module, pickle_load_args) File "/home/lt/anaconda3/envs/Free-View_Neural_Talking_Head_Synthesis/lib/python3.6/site-packages/torch/serialization.py", line 764, in _legacy_load magic_number = pickle_module.load(f, pickle_load_args) _pickle.UnpicklingError: A load persistent id instruction was encountered, but no persistent_load function was specified.

zhanglonghao1992 commented 2 years ago

@Liangtian96 你直接加载.pth.tar别用.pth