kinejing-open-source / projects /spatial-0 /scripts /fetch_worldmirror.py
zoah111's picture
Publish reviewed KineJing technical release (dataset, batch 13/16)
6da4e64 verified
Raw History Blame Contribute Delete
2.74 kB
"""Download the official WorldMirror checkpoint and verify publisher LFS SHA-256.
Local evaluation only. Review Tencent HY-World 2.0 community terms before public use.
Never load incomplete downloads or execute remote model code.
"""
import hashlib
import json
from pathlib import Path
import urllib.request
ROOT = Path(__file__).resolve().parents[1]
DESTINATION = ROOT.parents[1] / "work/tools/ComfyUI/models/WorldMirror-V2"
EXPECTED = "9fff06539d3d9e85338d7de1ffb5afffb7739fa5bf4d62b4b7c319b5ecdde54f"
def main():
for name in ["config.json", "model.safetensors"]:
expected = EXPECTED if name == "model.safetensors" else "5e40150577ef7d38e24d8d079a7126568a0ec9816dbfc61ebc99c67faf430ed9"
path = DESTINATION / "HY-WorldMirror-2.0" / name
path.parent.mkdir(parents=True, exist_ok=True)
if not path.exists():
url = "https://modelscope.cn/api/v1/models/Tencent-Hunyuan/HY-World-2.0/repo?Revision=master&FilePath=HY-WorldMirror-2.0%2F" + name
partial = path.with_suffix(path.suffix + ".incomplete")
request = urllib.request.Request(url, headers={"User-Agent": "KineWorld-local-evaluation/1.0"})
with urllib.request.urlopen(request, timeout=60) as response, partial.open("wb") as target:
total = 0
last_report = 0
while block := response.read(4 * 1024 * 1024):
target.write(block)
total += len(block)
if total - last_report >= 64 * 1024 * 1024:
print(f"{name}: {total / 1024**2:.0f} MiB", flush=True)
last_report = total
with partial.open("rb") as source:
actual = hashlib.file_digest(source, "sha256").hexdigest()
if actual != expected:
raise RuntimeError("Downloaded file checksum mismatch; incomplete file retained")
partial.replace(path)
else:
with open(path, "rb") as stream:
actual = hashlib.file_digest(stream, "sha256").hexdigest()
if actual != expected:
raise RuntimeError(f"Existing file not approved: {name}")
print(f"Verified {name}", flush=True)
record = {"repository": "tencent/HY-World-2.0", "model": "HY-WorldMirror-2.0",
"sha256": EXPECTED, "bytes": Path(path).stat().st_size,
"license": "Tencent HY-World 2.0 Community License",
"scope": "Local research candidate; no public deployment approved"}
(DESTINATION / "verified.json").write_text(json.dumps(record, indent=2), encoding="utf-8")
print("Publisher checkpoint hash verified", flush=True)
if __name__ == "__main__":
main()