Link the released pre-encoded data (wizard-precoded); restore script; reproduction steps
Browse files- README.md +9 -0
- code/README.md +8 -1
- code/scripts/restore_precoded.py +89 -0
README.md
CHANGED
|
@@ -30,6 +30,15 @@ The full training set has 50,115 windows (56 h). This repository holds the 26,44
|
|
| 30 |
| `code/` | training and inference code, see `code/README.md` | | |
|
| 31 |
| `examples/` | three ready-to-run inference cases with our outputs, see `examples/README.md` | | |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
Every folder has the same layout:
|
| 34 |
|
| 35 |
```text
|
|
|
|
| 30 |
| `code/` | training and inference code, see `code/README.md` | | |
|
| 31 |
| `examples/` | three ready-to-run inference cases with our outputs, see `examples/README.md` | | |
|
| 32 |
|
| 33 |
+
## Reproducing the model
|
| 34 |
+
|
| 35 |
+
1. **Pre-encoded training data**: [`yuzhewu207/wizard-precoded`](https://huggingface.co/datasets/yuzhewu207/wizard-precoded) — the exact training files (Wan2.2-VAE latents etc.) for all redistributable windows; `python code/scripts/restore_precoded.py --root <dir>` downloads and lays them out.
|
| 36 |
+
2. **Base model**: `Wan-AI/Wan2.2-TI2V-5B` (`WIZARD_WAN`).
|
| 37 |
+
3. **Code**: `code/` here (`pip install -e code`), one launch script per stage in `code/scripts/`; the weights each stage starts from are in `weights/` (see `weights/README.md`).
|
| 38 |
+
4. **Inference**: `code/README.md` → *Inference*, with the ready-made cases in `examples/`.
|
| 39 |
+
|
| 40 |
+
## Data layout
|
| 41 |
+
|
| 42 |
Every folder has the same layout:
|
| 43 |
|
| 44 |
```text
|
code/README.md
CHANGED
|
@@ -119,7 +119,14 @@ Most options that change *what* is trained are environment variables rather than
|
|
| 119 |
|
| 120 |
The training code reads **pre-encoded** windows (Wan2.2-VAE latents of the target and of the proxy video, text embeddings, per-cell geometry, memory banks and retrieval indices) under `$WIZARD_DATA`: `wan_v7/` (row file, proxy latents), `wan_mix5/` (target latents and text table), `wan_memroam/`, `wan_sfly/`, `wan_sfly_replay/`, `wan_lookback_geo/`, `wan_wedit/`.
|
| 121 |
|
| 122 |
-
The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
## Notes on the code
|
| 125 |
|
|
|
|
| 119 |
|
| 120 |
The training code reads **pre-encoded** windows (Wan2.2-VAE latents of the target and of the proxy video, text embeddings, per-cell geometry, memory banks and retrieval indices) under `$WIZARD_DATA`: `wan_v7/` (row file, proxy latents), `wan_mix5/` (target latents and text table), `wan_memroam/`, `wan_sfly/`, `wan_sfly_replay/`, `wan_lookback_geo/`, `wan_wedit/`.
|
| 121 |
|
| 122 |
+
**The pre-encoded data is released in [`yuzhewu207/wizard-precoded`](https://huggingface.co/datasets/yuzhewu207/wizard-precoded)** (804 GiB, the exact files the models were trained on, minus the WildWorld windows). Restore it with
|
| 123 |
+
|
| 124 |
+
```bash
|
| 125 |
+
python scripts/restore_precoded.py --root /path/to/wizard_data # download + extract + rewrite the absolute paths
|
| 126 |
+
export WIZARD_DATA=/path/to/wizard_data
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
and every script above runs unchanged (group `ww` simply has no rows). The dataset in this repository is the model-independent form of the same windows (target videos, decoded proxy videos, depth, cameras, memory metadata), for re-encoding with another backbone.
|
| 130 |
|
| 131 |
## Notes on the code
|
| 132 |
|
code/scripts/restore_precoded.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Download and restore the Wizard pre-encoded training data into one root folder (the $WIZARD_DATA of the training code).
|
| 3 |
+
|
| 4 |
+
python restore_precoded.py --root /path/to/wizard_data # download + extract + fix paths
|
| 5 |
+
python restore_precoded.py --root /path/to/wizard_data --verify # also check every file's sha256 against the manifests
|
| 6 |
+
python restore_precoded.py --root /path/to/wizard_data --dirs wan_v7,wan_mix --keep-tars # a subset, keep the downloaded shards
|
| 7 |
+
|
| 8 |
+
What it does:
|
| 9 |
+
1. downloads precoded/<dir>/shard-*.tar(.tsv) and precoded_meta/ from yuzhewu207/wizard-precoded (huggingface_hub; resumable);
|
| 10 |
+
2. extracts every shard into --root (members are paths relative to the data root, e.g. wan_v7/cond7/clip_<key>.pt);
|
| 11 |
+
3. copies precoded_meta/* over it (row files and text tables without the WildWorld rows);
|
| 12 |
+
4. the data was built under /data/yuzhewu/datasets: absolute symlinks (wan_mix5/clips/*, wan_v7/gbuf2, wan_v7/shield) and the absolute
|
| 13 |
+
paths inside the row files (*.jsonl, *.json, *.txt at the top of each folder) are rewritten to --root;
|
| 14 |
+
5. --verify: sha256 of every extracted file against the shard manifests.
|
| 15 |
+
Needs ~0.85 TB free (+0.8 TB while a shard is downloaded and extracted unless --stream is used, which deletes each tar after extraction; default).
|
| 16 |
+
With access to the private part (WildWorld windows) pass --private-repo yuzhewu207/wizard-repro: its v2/precoded_ww shards and the full row files are added.
|
| 17 |
+
"""
|
| 18 |
+
import argparse, hashlib, json, os, sys, tarfile, glob, shutil
|
| 19 |
+
|
| 20 |
+
OLD = "/data/yuzhewu/datasets"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def sha256(p, bs=1 << 22):
|
| 24 |
+
h = hashlib.sha256()
|
| 25 |
+
with open(p, "rb") as f:
|
| 26 |
+
for b in iter(lambda: f.read(bs), b""): h.update(b)
|
| 27 |
+
return h.hexdigest()
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def main():
|
| 31 |
+
ap = argparse.ArgumentParser()
|
| 32 |
+
ap.add_argument("--root", required=True); ap.add_argument("--repo", default="yuzhewu207/wizard-precoded")
|
| 33 |
+
ap.add_argument("--private-repo", default=""); ap.add_argument("--dirs", default="", help="comma list of folders (default: all)")
|
| 34 |
+
ap.add_argument("--dl", default="", help="download dir (default: <root>/_download)"); ap.add_argument("--keep-tars", action="store_true")
|
| 35 |
+
ap.add_argument("--verify", action="store_true"); ap.add_argument("--local", default="", help="use already-downloaded repo folder instead of downloading")
|
| 36 |
+
a = ap.parse_args()
|
| 37 |
+
from huggingface_hub import HfApi, hf_hub_download, snapshot_download
|
| 38 |
+
root = os.path.abspath(a.root); os.makedirs(root, exist_ok=True); dl = a.local or a.dl or os.path.join(root, "_download")
|
| 39 |
+
want = set(x for x in a.dirs.split(",") if x)
|
| 40 |
+
srcs = [(a.repo, "precoded/", "precoded_meta/")] + ([(a.private_repo, "v2/precoded_ww/", "v2/precoded_meta_full/")] if a.private_repo else [])
|
| 41 |
+
for repo, prefix, meta in srcs:
|
| 42 |
+
files = HfApi().list_repo_files(repo, repo_type="dataset") if not a.local else \
|
| 43 |
+
[os.path.relpath(p, dl) for p in glob.glob(f"{dl}/{prefix}**/*", recursive=True) + glob.glob(f"{dl}/{meta}**/*", recursive=True) if os.path.isfile(p)]
|
| 44 |
+
tars = sorted(f for f in files if f.startswith(prefix) and f.endswith(".tar") and (not want or f.split("/")[-2] in want))
|
| 45 |
+
print(f"{repo}: {len(tars)} shards", flush=True)
|
| 46 |
+
for i, t in enumerate(tars):
|
| 47 |
+
mark = os.path.join(root, "_restored", t.replace("/", "__") + ".done")
|
| 48 |
+
if os.path.exists(mark): continue
|
| 49 |
+
p = os.path.join(dl, t) if a.local else hf_hub_download(repo, t, repo_type="dataset", local_dir=dl)
|
| 50 |
+
m = os.path.join(dl, t + ".tsv") if a.local else hf_hub_download(repo, t + ".tsv", repo_type="dataset", local_dir=dl)
|
| 51 |
+
with tarfile.open(p) as tf: tf.extractall(root, filter="tar") if sys.version_info >= (3, 12) else tf.extractall(root)
|
| 52 |
+
os.makedirs(os.path.dirname(mark), exist_ok=True); shutil.copy(m, mark)
|
| 53 |
+
if not a.keep_tars and not a.local: os.remove(p)
|
| 54 |
+
print(f" [{i + 1}/{len(tars)}] {t}", flush=True)
|
| 55 |
+
metas = [f for f in files if f.startswith(meta)]
|
| 56 |
+
for f in metas:
|
| 57 |
+
p = os.path.join(dl, f) if a.local else hf_hub_download(repo, f, repo_type="dataset", local_dir=dl)
|
| 58 |
+
dst = os.path.join(root, f[len(meta):]); os.makedirs(os.path.dirname(dst), exist_ok=True); shutil.copy(p, dst)
|
| 59 |
+
print(f" meta: {len(metas)} files from {meta}", flush=True)
|
| 60 |
+
# absolute paths -> root
|
| 61 |
+
nl = nt = 0
|
| 62 |
+
for d in sorted(os.listdir(root)):
|
| 63 |
+
dd = os.path.join(root, d)
|
| 64 |
+
if not os.path.isdir(dd) or d.startswith("_"): continue
|
| 65 |
+
for base, dirs, fs in os.walk(dd):
|
| 66 |
+
for x in fs + dirs:
|
| 67 |
+
q = os.path.join(base, x)
|
| 68 |
+
if os.path.islink(q) and os.readlink(q).startswith(OLD):
|
| 69 |
+
t = root + os.readlink(q)[len(OLD):]; os.remove(q); os.symlink(t, q); nl += 1
|
| 70 |
+
for f in glob.glob(f"{dd}/*.jsonl") + glob.glob(f"{dd}/*.json") + glob.glob(f"{dd}/*.txt"):
|
| 71 |
+
s = open(f, encoding="utf-8").read()
|
| 72 |
+
if OLD in s: open(f, "w", encoding="utf-8").write(s.replace(OLD, root)); nt += 1
|
| 73 |
+
print(f"rewrote {nl} symlinks and {nt} row/index files to {root}", flush=True)
|
| 74 |
+
if a.verify:
|
| 75 |
+
bad = n = 0
|
| 76 |
+
for m in glob.glob(os.path.join(root, "_restored", "*.done")):
|
| 77 |
+
for line in open(m):
|
| 78 |
+
size, h, rel = line.rstrip("\n").split("\t", 2)
|
| 79 |
+
if h.startswith("symlink->"): continue
|
| 80 |
+
n += 1; p = os.path.join(root, rel)
|
| 81 |
+
if not os.path.exists(p) or sha256(p) != h: bad += 1; print("BAD", rel)
|
| 82 |
+
print(f"verified {n} files, {bad} bad")
|
| 83 |
+
dangling = [q for q in glob.glob(f"{root}/wan_mix5/clips/*") if os.path.islink(q) and not os.path.exists(q)]
|
| 84 |
+
print(f"dangling wan_mix5/clips links: {len(dangling)}" + (" (expected: the WildWorld clips are not in the public part)" if dangling and not a.private_repo else ""))
|
| 85 |
+
print(f"done. export WIZARD_DATA={root}")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
+
main()
|