MuseTalk icon indicating copy to clipboard operation
MuseTalk copied to clipboard

怎么设置 weights_only=False?

Open peng0105 opened this issue 7 months ago • 3 comments

load unet model from ./models/musetalkV15/unet.pth Traceback (most recent call last): File "/anaconda3/envs/musetalk/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/anaconda3/envs/musetalk/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/root/MuseTalk/scripts/inference.py", line 276, in main(args) File "/anaconda3/envs/musetalk/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) File "/root/MuseTalk/scripts/inference.py", line 72, in main fp = FaceParsing( File "/root/MuseTalk/musetalk/utils/face_parsing/init.py", line 12, in init self.net = self.model_init() File "/root/MuseTalk/musetalk/utils/face_parsing/init.py", line 62, in model_init net = BiSeNet(resnet_path) File "/root/MuseTalk/musetalk/utils/face_parsing/model.py", line 233, in init self.cp = ContextPath(resnet_path) File "/root/MuseTalk/musetalk/utils/face_parsing/model.py", line 95, in init self.resnet = Resnet18(resnet_path) File "/root/MuseTalk/musetalk/utils/face_parsing/resnet.py", line 69, in init self.init_weight(model_path) File "/root/MuseTalk/musetalk/utils/face_parsing/resnet.py", line 83, in init_weight state_dict = torch.load(model_path) #modelzoo.load_url(resnet18_url) File "/anaconda3/envs/musetalk/lib/python3.10/site-packages/torch/serialization.py", line 1541, in load return _legacy_load( File "/anaconda3/envs/musetalk/lib/python3.10/site-packages/torch/serialization.py", line 1787, in _legacy_load return legacy_load(f) File "/anaconda3/envs/musetalk/lib/python3.10/site-packages/torch/serialization.py", line 1654, in legacy_load raise RuntimeError( RuntimeError: Cannot use weights_only=True with files saved in the legacy .tar format. In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.

peng0105 avatar May 28 '25 03:05 peng0105

你自己进去把源码改下不就好了

codestart-zhu avatar May 29 '25 00:05 codestart-zhu

It specifies torch 2.0.1. You probably have torch 2.6.0 or higher installed. Torch 2.5.0 might work.

a-macdougall avatar Jun 02 '25 01:06 a-macdougall

降低torch版本或者去torch.load的地方改一下

jefferyglt avatar Jun 05 '25 07:06 jefferyglt