# Reproducing TopoRig training and evaluation Dataset: [SoroushMehraban/TopoRig_Dataset](https://huggingface.co/datasets/SoroushMehraban/TopoRig_Dataset). These instructions target the recovered-metadata supplement. Download `main` **after that supplement is uploaded** and record the resolved dataset commit. The original payload release `fd4f1f9f1996c139db8bf0ff85b3048f6e250d61` contains all 228 verified shards but lacks the recovered training metadata. The supplement changes metadata and documentation only. Run these commands from the TopoRig **code checkout**. The Hugging Face repository holds data and reference assets, not the Python code or trained checkpoints. Record the code commit, dataset commit, resolved configurations, environment, and external metadata/WAFT versions with each experiment. ## What this release provides The four shard collections contain 114,319 original files: 103,829 PNG images, 6,994 rigged FBXs, and 3,496 custom landmark JSON files. The source bytes and full identity strings are preserved. `metadata/` contains the inventory, AU table, availability, and recorded exclusions. `reference_assets/` contains demo meshes, sample images, and ICT/MetaHuman oral assemblies. The metadata supplement adds the original mesh split assignments, 624 ICT training landmark mappings, and 350 separately recorded ICT benchmark mappings. `metadata/reproduction.json` records source checksums, identity renaming, coverage, and structural validation. All nonexcluded ICT training and validation identities have mappings. Custom mappings remain in the existing mesh shards. The original 700-row benchmark is included as `metadata/evaluation_manifest.csv`: 350 ICT and 350 custom heads. Its recorded row order, pair IDs, source splits, and membership are preserved. Historical mesh names are canonicalized and old absolute FBX paths become portable relative paths. Every selected mesh and its landmark mapping is present. The release also has known inventory gaps: `img_00100` has no mesh, `img_02270` has no custom landmark mapping, and 32 neutral identities have no expressed images. Preserve supplied exclusions and consult `metadata/availability.jsonl` when choosing additional samples. ## What is still needed After uploading the supplement, the data needed for the default training and validation selections is present. Runtime preparation is still required. | Input | Status and use | | --- | --- | | `metadata/ict_split.csv`, `metadata/custom_split.csv` | Recovered original train/val/test assignments, with canonical identity names | | `metadata/ict_landmarks/` | 624 mappings, covering all nonexcluded ICT train/val identities | | `metadata/ict_eval_landmarks/` | 350 recorded benchmark mappings; separate from training mappings | | `metadata/evaluation_manifest.csv` | Recovered original 700-row benchmark; required for the separate physical evaluation | | WAFT source and pretrained dependencies | Recovered version and checksums; download separately using section 1 | Users also need the current TopoRig code and compatible runtime dependencies: PyTorch, Blender's `bpy`, and (for Stage 2) MediaPipe and WAFT's dependencies. The dataset repository contains neither the code nor an environment image. Provide an accessible code release containing these preparation/download tools; local, uncommitted changes are not part of a GitHub clone. The configured [GitHub code repository](https://github.com/SoroushMehraban/TopoRig_Project) returned HTTP 404 to an unauthenticated check on 2026-09-13, so public code access has not been verified. Make the code accessible to intended users and publish the current preparation/download changes with it. The main Stage 2 image recipe uses `split: all`, so a separate `image_split.csv` is not required for that recipe. The missing custom mapping for `img_02270` is covered by the supplied exclusion list. Tensor, eyelid, and WAFT supervision caches are generated by section 3 and need not be distributed. Pretrained TopoRig checkpoints are intentionally excluded and are not required to train from scratch; Stage 2 uses the checkpoint produced by Stage 1. ## 1. Environment and download Python 3.10+ is required. Create an environment, install the appropriate CUDA-enabled PyTorch build for your machine, then install the project: ```bash python -m venv .venv source .venv/bin/activate python -m pip install -e '.[training,rendering,preprocessing,hub,test]' python -m dataset.hf_assets --repo-id SoroushMehraban/TopoRig_Dataset \ --revision main \ --local-dir /path/to/TopoRig_download ``` Blender's `bpy` must be importable by this same Python interpreter for FBX conversion. Install a Blender/Python combination compatible with your platform. MediaPipe is needed for image landmark detection. Stage 2 additionally requires WAFT and its pretrained dependencies, acquired below. The preparation check reports missing runtime modules and required weight files before cache work. ```bash export TOPORIG_DATA_ROOT=/path/to/TopoRig_download export TOPORIG_CACHE_ROOT=/path/to/TopoRig_cache export TOPORIG_METADATA_ROOT="$TOPORIG_DATA_ROOT/metadata" export TOPORIG_REFERENCE_ROOT="$TOPORIG_DATA_ROOT/reference_assets" export TOPORIG_OUTPUT_ROOT=/path/to/TopoRig_runs export TOPORIG_RESULTS_ROOT=/path/to/TopoRig_results export TOPORIG_WAFT_ROOT=/path/to/WAFT mkdir -p "$TOPORIG_RESULTS_ROOT" ``` Keep derived caches and outputs outside the downloaded dataset. Use the existing staged folder as `TOPORIG_DATA_ROOT` to work entirely offline. The full download plus extracted source assets needs about 225 GiB, with additional space for derived caches. Training extracts the required files on first use and reuses them on subsequent runs. No Hugging Face `datasets` or `webdataset` Python package is required by the TopoRig training adapter. To verify a full download without extracting another copy: ```bash python scripts/validate_dataset_layout.py --data-root "$TOPORIG_DATA_ROOT" \ --checksums --output "$TOPORIG_RESULTS_ROOT/dataset-validation.json" ``` This expects all four collections. Add `--images` to decode and integrity-check every PNG; this is slower. It verifies data integrity, not historical selection or Blender/WAFT readiness. ### WAFT for Stage 2 The recovered checkout is the clean upstream commit `b152ff1cad1af8c185ee7b141997c48ff3334c87` of [princeton-vl/WAFT](https://github.com/princeton-vl/WAFT/tree/b152ff1cad1af8c185ee7b141997c48ff3334c87). Use a new directory for this checkout: ```bash git clone https://github.com/princeton-vl/WAFT.git "$TOPORIG_WAFT_ROOT" git -C "$TOPORIG_WAFT_ROOT" checkout b152ff1cad1af8c185ee7b141997c48ff3334c87 git -C "$TOPORIG_WAFT_ROOT" submodule update --init --recursive python -m pip install -r "$TOPORIG_WAFT_ROOT/requirements.txt" python -m pip install gdown mkdir -p "$TOPORIG_WAFT_ROOT/ckpts" "$TOPORIG_WAFT_ROOT/depth-anything-ckpts" gdown 1CxzBQx0iSg6AyIgt6MF0ROlF_cAeZLPC \ -O "$TOPORIG_WAFT_ROOT/ckpts/waft_a1_adaptation.pth" hf download depth-anything/Depth-Anything-V2-Small depth_anything_v2_vits.pth \ --revision 03876f8651c73a60fe4c2c48294e09fcb6838fcf \ --local-dir "$TOPORIG_WAFT_ROOT/depth-anything-ckpts" ``` The adaptation weight comes from the [official WAFT model zoo](https://github.com/princeton-vl/WAFT/blob/b152ff1cad1af8c185ee7b141997c48ff3334c87/README.md#model-zoo). The [official Depth Anything V2 Small checkpoint](https://huggingface.co/depth-anything/Depth-Anything-V2-Small/tree/03876f8651c73a60fe4c2c48294e09fcb6838fcf) has exactly the same 239 tensors as the recovered backbone file; serialization bytes differ. The following hashes verify the documented downloads and config: ```bash python - <<'PYWAFT' import hashlib, os from pathlib import Path root = Path(os.environ["TOPORIG_WAFT_ROOT"]) expected = { "config/a1/tar-c-t.json": "9144f400957f6abe983f9627303ea3e1c7b73c745cbafe4193e1c764e8375422", "ckpts/waft_a1_adaptation.pth": "9f4b24f48b3937eca690a12b73bc3190effde6d4d4c87db01998fe63d846397f", "depth-anything-ckpts/depth_anything_v2_vits.pth": "715fade13be8f229f8a70cc02066f656f2423a59effd0579197bbf57860e1378", } for name, digest in expected.items(): actual = hashlib.sha256((root / name).read_bytes()).hexdigest() if actual != digest: raise SystemExit(f"Checksum mismatch: {name}") print("WAFT configuration and weights verified.") PYWAFT ``` WAFT's upstream environment uses Python 3.12, PyTorch 2.7.0 and CUDA 12.8, and recommends a compatible [xformers](https://github.com/facebookresearch/xformers) build. These are upstream version references, not a validated lockfile for the complete TopoRig stack. Choose compatible Blender/Python and CUDA packages and save `python -m pip freeze` with the run. `timm` can download additional pretrained ResNet weights on first construction; initialize the model on an internet-connected machine before running offline. `metadata/waft.json` records the recovered source and file checksums, including the alternative serialization hash of the lab's Depth Anything file. WAFT code and weight files are separate external dependencies, with their own licenses. They are not part of the TopoRig academic-use dataset payload. ## 2. Recovered metadata and landmarks Use the downloaded `metadata/` directly through `TOPORIG_METADATA_ROOT`. No split generation or landmark transfer is needed for the recorded train/val selection. Original CSV row order and assignments are preserved; only historical mesh names are canonicalized, for example `v2_img_00006_2_fit_100k_faces` becomes `v2_img_00006`. | Source | Original train / val / test | After recorded exclusions | | --- | --- | --- | | ICT | 504 / 63 / 63 | 499 / 63 / 62 | | Custom | 2,797 / 350 / 350 | 2,796 / 350 / 350 | The six ICT split identities without mappings are all in the existing ICT exclusion list. Seven unrelated hashed cache filenames were omitted. The 624 training and 350 evaluation mappings each contain 468 entries; imported JSON bytes are unchanged, and vertex indices were checked against the existing FBX geometry audit. This structural check does not replace runtime Blender import or visual validation of landmark placement. The default Stage 2 image recipe keeps its historical `split: all` and non-`v2_` identity profile. It does not require an `image_split.csv`. Benchmark membership is separate from the mesh-training splits; the 350 mapping filenames alone do not define pair IDs, source splits, or custom benchmark membership. The maintainer import script `scripts/prepare_reproduction_metadata.py` checks original records and builds the metadata supplement; ordinary dataset users do not need to run it. For a new experiment with additional ICT identities, prepare and validate additional mappings rather than filling missing mappings with empty JSON files. ## 3. Preparation These checks report missing files and runtime packages before launching caches: ```bash python scripts/prepare_training.py --config config/train.yaml --step check python scripts/prepare_training.py --config config/stage2.yaml --step check python scripts/prepare_training.py --config config/train.yaml --step all python scripts/prepare_training.py --config config/stage2.yaml --step all ``` Stage 1 prepares both mesh streams for train and validation. Stage 2 prepares all mesh streams, image-branch neutral meshes, validated eyelid landmarks, and WAFT/image supervision, in that order. Individual steps are `mesh`, `image-meshes`, `eyelids`, and `waft`. `--step waft` uses the resolved Stage 2 configuration and does not require a Stage 1 checkpoint because it prepares caches without training. For distributed cache work, the underlying `scripts/cache_mesh_dataset.py`, `scripts/cache_image_meshes.py`, and `scripts/cache_validated_welded_eyelid_landmarks.py` accept `--i` and `--n` for one-based task partitioning. These partitions are independent of archive shards and must use the same dataset revision and cache root. ## 4. Train the two stages The recorded setup uses four GPUs, batch size 4 per GPU, seed 7, 20 Stage 1 epochs at learning rate 0.0005, and 10 Stage 2 epochs at 0.0001. Save the resolved configurations before running: ```bash python scripts/launch_training.py --config config/train.yaml --gpus 4 --print-config \ > "$TOPORIG_RESULTS_ROOT/stage1-resolved.yaml" python scripts/launch_training.py --config config/stage2.yaml --gpus 4 --print-config \ > "$TOPORIG_RESULTS_ROOT/stage2-resolved.yaml" python scripts/launch_training.py --config config/train.yaml --gpus 4 python scripts/launch_training.py --config config/stage2.yaml --gpus 4 \ --initial-checkpoint "$TOPORIG_OUTPUT_ROOT/phase1/checkpoints/best.pt" ``` Default run names are `phase1` and `phase2`. Stage 2 initializes model weights from Stage 1 and starts its own optimizer/schedule. To continue an interrupted stage, pass `--resume /path/to/that/stage/checkpoint.pt`; this restores the optimizer, scheduler, RNG, epoch, and global step. Do not combine initialization and resume. A single-GPU run can use `python train.py --config ...` directly; changing GPU count changes the effective global batch size. Keep the AU lists and exclusion files unchanged for the main experiment. Stage 1 uses non-gaze controls, Stage 2 retains the recorded mesh streams and eight eye-region image controls, and best checkpoints are selected by mesh MAE. W&B logging is disabled by default; `--use-wandb` opts in. For SLURM, set site-specific modules and optionally `TOPORIG_VENV`, then: ```bash TOPORIG_GPUS=4 bash scripts/submit_landmark_dropout_two_stage.sh \ --account=YOUR_ACCOUNT --gres=gpu:4 --cpus-per-task=16 --mem=160G --time=36:00:00 ``` The submitter connects the stages with a job dependency and passes Stage 1's checkpoint to Stage 2. Resource flags must match your cluster. ## 5. Evaluate checkpoints Use the supplied `metadata/evaluation_manifest.csv`. It contains: ```text index,dataset_index,pair_id,paired_test_identity,dataset,mesh_id,fbx_path,source_split ``` `dataset` is `ict` or `pixel3d` (the latter means `meshes_custom`). `mesh_id` is the full identity. `paired_test_identity` is `true` or `false`. Keep the original pair IDs and split labels. `fbx_path` is provenance: the evaluator locates FBXs under the configured collections, preserving membership even if old absolute paths no longer exist. The default benchmark expects exactly 350 heads from each source; duplicates within a source are rejected. `--head-count` supports a separately reported smaller experiment. ```bash export TOPORIG_EVAL_MANIFEST="$TOPORIG_METADATA_ROOT/evaluation_manifest.csv" python scripts/evaluate_toporig_checkpoint_physical.py \ --paired-manifest "$TOPORIG_EVAL_MANIFEST" --prepare-only python scripts/evaluate_toporig_checkpoint_physical.py \ --paired-manifest "$TOPORIG_EVAL_MANIFEST" \ --checkpoint "$TOPORIG_OUTPUT_ROOT/phase1/checkpoints/best.pt" \ --output-dir "$TOPORIG_RESULTS_ROOT/physical_evaluation/stage1" --device cuda python scripts/evaluate_toporig_checkpoint_physical.py \ --paired-manifest "$TOPORIG_EVAL_MANIFEST" \ --checkpoint "$TOPORIG_OUTPUT_ROOT/phase2/checkpoints/best.pt" \ --output-dir "$TOPORIG_RESULTS_ROOT/physical_evaluation/stage2" --device cuda python scripts/aggregate_toporig_physical_evaluations.py \ --result-root "$TOPORIG_RESULTS_ROOT/physical_evaluation" --runs stage1 stage2 ``` ICT evaluation defaults to `metadata/ict_eval_landmarks/`; training uses `metadata/ict_landmarks/`. The evaluator checks selected mappings before FBX conversion and reports missing files. Evaluation materializes only the recorded mesh identities when given a shard release. It uses 45 ICT AUs and 41 reliable custom AUs, a 0.01 mm moving-vertex threshold, and a 240 mm standard head height. Reports include per-sample, per-head, per-AU, and combined physical/standardized errors. Missing checkpoints must be trained or obtained separately; the excluded checkpoint directory is not downloaded by these instructions. ## Validation limits Run `python -m pytest -q` from the code checkout for regression tests. The release preparation tests cover canonical/sharded loading, checksum corruption, missing landmarks, identity namespaces, reference downloads, and exact evaluation membership. They do not substitute for a full GPU run with Blender, MediaPipe, WAFT, and the original metadata. Preserve each run's actual dependency versions and results alongside its configuration.