Files
hand-motion-pipeline/scripts/run_red_mirrored_handflow.py
liyang ae28d55f81 Update to 2026-09-17 pipeline snapshot; add weights, L20 assets and recording via Git LFS
Source: RGB-D -> Dyn-HaMR -> L20 retargeting -> FoundationPose -> reference repair -> SPIDER,
documented in docs/PIPELINE_LATEST.md and docs/SETUP_AND_WEIGHTS.md. Adds FoundationPose and
nvdiffrast upstream snapshots, requirements/pipeline_venv.txt and the FoundationPose weight
manifest/downloader.

Assets (Git LFS): weights/ (WiLoR detector, HandFlow denoiser, UniDepth-L), FoundationPose
checkpoints, HaMeR checkpoint, Dyn-HaMR HMP model and BMC constraints, L20 URDF/meshes, the
20260915_171525 D405 recording and the two box CADs. MANO models are not redistributed
(third_party/hamer/_DATA/data/mano/README.txt). Environments, caches and run outputs excluded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 11:43:37 +08:00

17 lines
1.7 KiB
Python

"""Prepare RGB-only HandFlow baseline for both hands with fixed camera calibration."""
import os,subprocess,json
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];OUT=ROOT/'output/depth_ablation_red_20260916';m=json.loads((ROOT/'docs/20260916_104026/intrinsics.json').read_text())
env=os.environ.copy();env.update(PYTHONPATH=str(ROOT),LD_LIBRARY_PATH='',OMP_NUM_THREADS='4',MKL_NUM_THREADS='4',OPENBLAS_NUM_THREADS='4',TORCH_HOME=str(ROOT/'.torch_cache'),HF_HOME=str(ROOT/'.hf_cache'),HF_HUB_OFFLINE='1',TRANSFORMERS_OFFLINE='1',TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD='1',PYTHONUNBUFFERED='1',HAMER_CKPT=str(ROOT/'third_party/hamer/_DATA/hamer_ckpts/checkpoints/hamer.ckpt'),DETECTOR_CKPT=str(ROOT/'weights/detector.pt'),MANO_ROOT=str(ROOT/'third_party/hamer/_DATA/data/mano'),HANDFLOW_NORMALIZATION_STATS=str(ROOT/'weights/normalization_stats.npz'))
m['cx']=m['width']-1-m['cx']
for side in ['left_mirrored']:
dst=OUT/side;dst.mkdir(exist_ok=True)
if (dst/'handflow_results.npz').exists():continue
cmd=[str(ROOT/'.venv/bin/python'),'-u','scripts/demo.py','--input',str(OUT/'input_315_mirrored.mkv'),'--fm_ckpt',str(ROOT/'weights/handflow_denoiser.pt'),'--intrinsics',','.join(str(m[k]) for k in ['fx','fy','cx','cy']),'--fix_camera','--side','right','--output_dir',str(dst),'--save_npz',str(dst/'handflow_results.npz')]
print('Running',side,flush=True)
for attempt in range(2):
if (dst/'handflow_results.npz').exists():break
with (dst/'inference.log').open('a') as f:subprocess.run(cmd,cwd=ROOT,env=env,stdout=f,stderr=subprocess.STDOUT,check=True)
assert (dst/'handflow_results.npz').exists(), f'Missing final results: {side}'
print('Mirrored-left RGB-only baseline complete',flush=True)