Merge pull request #39 from anupamme/fix-repo-ai-video-editor-fix-pickles-in-pytorch-safe-load

fix: replace unsafe pickle usage in export_joyvasa_audio.py...
This commit is contained in:
Martin Delophy authored and GitHub committed 2026-07-22 17:25:04 +08:00
commit da65d8b1ed
3 files changed
+12 -9

No files matched your search

+3 -2
View File
@@ -12,7 +12,7 @@ import argparse
import hashlib
import json
import sys
from pathlib import Path
from pathlib import Path, PosixPath
import numpy as np
import onnx
@@ -68,7 +68,8 @@ def main() -> None:
sys.path.insert(0, str(args.source))
from src.modules.hubert import HubertModel
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False)
torch.serialization.add_safe_globals([argparse.Namespace, PosixPath])
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True)
config = HubertConfig.from_json_file(str(args.hubert_config))
encoder = HubertModel(config).eval()
encoder_prefix = "audio_encoder."
+6 -5
View File
@@ -1,8 +1,8 @@
"""Export the pinned JoyVASA diffusion denoiser to a browser-oriented ONNX graph.
The checkpoint pickle global list must be audited before running this script. The
pinned checkpoint currently contains only argparse.Namespace, pathlib.PosixPath,
collections.OrderedDict, and PyTorch tensor rebuild/storage globals.
The checkpoint contains argparse.Namespace, pathlib.PosixPath, collections.OrderedDict,
and PyTorch tensor rebuild/storage globals. The non-default classes are explicitly
allowlisted via add_safe_globals; all others are rejected by weights_only=True.
"""
from __future__ import annotations
@@ -11,7 +11,7 @@ import argparse
import hashlib
import json
import sys
from pathlib import Path
from pathlib import Path, PosixPath
import numpy as np
import onnx
@@ -54,7 +54,8 @@ def main() -> None:
dit_module.enc_dec_mask = cpu_enc_dec_mask
DenoisingNetwork = dit_module.DenoisingNetwork
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False)
torch.serialization.add_safe_globals([argparse.Namespace, PosixPath])
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True)
checkpoint_args = payload["args"]
checkpoint_expected = {
"n_diff_steps": 50,
+3 -2
View File
@@ -6,7 +6,7 @@ import argparse
import hashlib
import json
import pickle
from pathlib import Path
from pathlib import Path, PosixPath
import numpy as np
import torch
@@ -32,7 +32,8 @@ def main() -> None:
if sha256(args.template) != EXPECTED_TEMPLATE_SHA256:
raise RuntimeError("Unexpected JoyVASA motion template")
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=False)
torch.serialization.add_safe_globals([argparse.Namespace, PosixPath])
payload = torch.load(args.checkpoint, map_location="cpu", weights_only=True)
# The pinned 3.6KB pickle was audited before use and contains only a dict,
# NumPy ndarray reconstruction, ndarray, and dtype globals.
with args.template.open("rb") as handle: