Spaces:
Running
Running
Download docker_patch.py from STATICAI/Motion-Rig: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/STATICAI/Motion-Rig/resolve/807bba418da4e4600da88ae034c96c9fe0d49b2f/docker_patch.py
- Command line
-
hf download hf://spaces/STATICAI/Motion-Rig@807bba418da4e4600da88ae034c96c9fe0d49b2f/docker_patch.py
-
curl -L -o docker_patch.py https://huggingface.co/spaces/STATICAI/Motion-Rig/resolve/807bba418da4e4600da88ae034c96c9fe0d49b2f/docker_patch.py
2.07 kB
| """Build-only patches to the pinned existing upstream; never modifies /data.""" | |
| from pathlib import Path | |
| import shutil | |
| root = Path("/opt/space/upstream") | |
| def replace(path,old,new,count=1): | |
| source=path.read_text() | |
| if source.count(old) != count: | |
| raise RuntimeError(f"Upstream patch mismatch: {path} expected {count} occurrences of {old!r}") | |
| path.write_text(source.replace(old,new)) | |
| app=root/"app.py" | |
| replace(app,"import spaces # isort:skip","") | |
| replace(app,"@spaces.GPU\n","",2) | |
| replace(app,'device = torch.device("cuda" if torch.cuda.is_available() else "cpu")', | |
| 'assert torch.cuda.is_available(), "Dedicated CUDA GPU required"\n device = torch.device("cuda")') | |
| replace(app," cmd += \" > /dev/null 2>&1\"", | |
| ' cmd += ""') | |
| replace(app," os.system(cmd)", | |
| ' import shlex, subprocess\n subprocess.run(shlex.split(cmd), check=True, timeout=300)') | |
| replace(app,' fbx2glb_cmd += " > /dev/null 2>&1"', | |
| ' fbx2glb_cmd += ""') | |
| replace(app," os.system(fbx2glb_cmd)", | |
| ' import shlex, subprocess\n subprocess.run(shlex.split(fbx2glb_cmd), check=True, timeout=300)') | |
| additional=root/"util/dataset_mixamo_additional.py" | |
| old='KINEMATIC_TREE = get_kinematic_tree(TEMPLATE_PATH, BONES_IDX_DICT)\nassert len(KINEMATIC_TREE) == len(MIXAMO_JOINTS)' | |
| new='if os.path.isfile(TEMPLATE_PATH):\n KINEMATIC_TREE = get_kinematic_tree(TEMPLATE_PATH, BONES_IDX_DICT)\n assert len(KINEMATIC_TREE) == len(MIXAMO_JOINTS)\nelse:\n KINEMATIC_TREE = dataset_mixamo.KINEMATIC_TREE' | |
| replace(additional,old,new) | |
| for name in ("data","output"): | |
| path=root/name | |
| backup=root/(name+".bundled") | |
| if path.exists(): | |
| # Docker COPY inputs may be a separate mount; rename can fail EXDEV. | |
| # Copy then remove in the image so runtime can make the /data symlink. | |
| shutil.copytree(path,backup,symlinks=True) | |
| shutil.rmtree(path) | |
| print("BUILD_PATCH_PASS: dedicated CUDA, checked exports, standard skeleton") | |