From 044f6a9ad37013054ac798b099bde22a4bd85a3e Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 4 May 2026 21:42:24 +0800 Subject: [PATCH] Fix unsafe torch.load with weights_only=False Change torch.load calls to use weights_only=True to prevent arbitrary code execution via pickled objects. The loaded files contain dicts of tensors (e.g., cached prompt outputs) which are supported by weights_only=True in PyTorch 2.0+. This aligns with the existing safe usage in vibevoice_tokenizer_processor.py which already uses weights_only=True. Co-Authored-By: Claude Opus 4.7 --- demo/realtime_model_inference_from_file.py | 2 +- demo/web/app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/realtime_model_inference_from_file.py b/demo/realtime_model_inference_from_file.py index 1d56b07a..dbf24601 100644 --- a/demo/realtime_model_inference_from_file.py +++ b/demo/realtime_model_inference_from_file.py @@ -222,7 +222,7 @@ def main(): target_device = args.device if args.device != "cpu" else "cpu" voice_sample = voice_mapper.get_voice_path(args.speaker_name) print(f"Using voice preset for {args.speaker_name}: {voice_sample}") - all_prefilled_outputs = torch.load(voice_sample, map_location=target_device, weights_only=False) + all_prefilled_outputs = torch.load(voice_sample, map_location=target_device, weights_only=True) # Prepare inputs for the model inputs = processor.process_input_with_cached_prompt( diff --git a/demo/web/app.py b/demo/web/app.py index 1b45117e..6165ce02 100644 --- a/demo/web/app.py +++ b/demo/web/app.py @@ -161,7 +161,7 @@ def _ensure_voice_cached(self, key: str) -> Tuple[object, Path, str]: prefilled_outputs = torch.load( preset_path, map_location=self._torch_device, - weights_only=False, + weights_only=True, ) self._voice_cache[key] = prefilled_outputs