Spaces:
Paused
Paused
Add skeleton template selector (articulation/mixamo/vroid)
Browse files
demo.py
CHANGED
|
@@ -199,6 +199,8 @@ MODEL_CKPTS = [
|
|
| 199 |
"experiments/articulation_xl_quantization_256_token_4/grpo_1400.ckpt",
|
| 200 |
]
|
| 201 |
|
|
|
|
|
|
|
| 202 |
HF_PATHS = [
|
| 203 |
"None",
|
| 204 |
]
|
|
@@ -328,6 +330,7 @@ def run_rig(
|
|
| 328 |
output_paths: List[Path],
|
| 329 |
model_ckpt: str,
|
| 330 |
hf_path: Optional[str],
|
|
|
|
| 331 |
):
|
| 332 |
assert len(filepaths) == len(output_paths)
|
| 333 |
ensure_bpy_server_started()
|
|
@@ -336,7 +339,7 @@ def run_rig(
|
|
| 336 |
datapath = {
|
| 337 |
"data_name": None,
|
| 338 |
"loader": "bpy_server",
|
| 339 |
-
"filepaths": {
|
| 340 |
}
|
| 341 |
|
| 342 |
dataset_config = DatasetConfig.parse(
|
|
@@ -355,7 +358,7 @@ def run_rig(
|
|
| 355 |
process_fn=model._process_fn,
|
| 356 |
)
|
| 357 |
|
| 358 |
-
dataloader = module.predict_dataloader()[
|
| 359 |
|
| 360 |
results_out = []
|
| 361 |
infer_device = model.device if model is not None else "cuda"
|
|
@@ -375,7 +378,7 @@ def run_rig(
|
|
| 375 |
# Hung bpy worker: restart it and retry this file once.
|
| 376 |
print("[run_rig] load timed out — restarting bpy worker and retrying once", flush=True)
|
| 377 |
ensure_bpy_server_started(force=True)
|
| 378 |
-
dataloader_iter = iter(module.predict_dataloader()[
|
| 379 |
for _ in range(i):
|
| 380 |
next(dataloader_iter, None)
|
| 381 |
batch = next(dataloader_iter)
|
|
@@ -525,6 +528,7 @@ def run_cli(args):
|
|
| 525 |
outputs,
|
| 526 |
args.model_ckpt,
|
| 527 |
args.hf_path,
|
|
|
|
| 528 |
)
|
| 529 |
|
| 530 |
|
|
@@ -546,6 +550,7 @@ def _gpu_duration(
|
|
| 546 |
use_postprocess,
|
| 547 |
model_ckpt,
|
| 548 |
hf_path,
|
|
|
|
| 549 |
):
|
| 550 |
# Cold workers spend ~30–60 s importing bpy + loading the model before
|
| 551 |
# any GPU work. Give every request a generous 240 s floor.
|
|
@@ -566,6 +571,7 @@ def run_gradio(
|
|
| 566 |
use_postprocess,
|
| 567 |
model_ckpt,
|
| 568 |
hf_path,
|
|
|
|
| 569 |
):
|
| 570 |
try:
|
| 571 |
if not files:
|
|
@@ -592,6 +598,7 @@ def run_gradio(
|
|
| 592 |
outputs,
|
| 593 |
model_ckpt,
|
| 594 |
hf_path,
|
|
|
|
| 595 |
)
|
| 596 |
|
| 597 |
# Collect successfully exported files
|
|
@@ -703,6 +710,13 @@ def build_gradio_app():
|
|
| 703 |
info="Beam-search width. Larger = higher quality but slower; 1 disables beam search.",
|
| 704 |
)
|
| 705 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 706 |
gr.Markdown("**Pipeline toggles**")
|
| 707 |
use_skeleton = gr.Checkbox(
|
| 708 |
False,
|
|
@@ -751,6 +765,7 @@ def build_gradio_app():
|
|
| 751 |
use_postprocess,
|
| 752 |
model_ckpt,
|
| 753 |
hf_path,
|
|
|
|
| 754 |
],
|
| 755 |
outputs=[log, output],
|
| 756 |
)
|
|
@@ -790,6 +805,8 @@ if __name__ == "__main__":
|
|
| 790 |
|
| 791 |
parser.add_argument("--model_ckpt", default=MODEL_CKPTS[0] if MODEL_CKPTS else "")
|
| 792 |
parser.add_argument("--hf_path", default=None)
|
|
|
|
|
|
|
| 793 |
|
| 794 |
parser.add_argument("--gradio", action="store_true")
|
| 795 |
|
|
|
|
| 199 |
"experiments/articulation_xl_quantization_256_token_4/grpo_1400.ckpt",
|
| 200 |
]
|
| 201 |
|
| 202 |
+
SKELETON_CLASSES = ["articulation", "mixamo", "vroid"]
|
| 203 |
+
|
| 204 |
HF_PATHS = [
|
| 205 |
"None",
|
| 206 |
]
|
|
|
|
| 330 |
output_paths: List[Path],
|
| 331 |
model_ckpt: str,
|
| 332 |
hf_path: Optional[str],
|
| 333 |
+
skeleton_cls: str = "articulation",
|
| 334 |
):
|
| 335 |
assert len(filepaths) == len(output_paths)
|
| 336 |
ensure_bpy_server_started()
|
|
|
|
| 339 |
datapath = {
|
| 340 |
"data_name": None,
|
| 341 |
"loader": "bpy_server",
|
| 342 |
+
"filepaths": {skeleton_cls: [str(p) for p in filepaths]},
|
| 343 |
}
|
| 344 |
|
| 345 |
dataset_config = DatasetConfig.parse(
|
|
|
|
| 358 |
process_fn=model._process_fn,
|
| 359 |
)
|
| 360 |
|
| 361 |
+
dataloader = module.predict_dataloader()[skeleton_cls]
|
| 362 |
|
| 363 |
results_out = []
|
| 364 |
infer_device = model.device if model is not None else "cuda"
|
|
|
|
| 378 |
# Hung bpy worker: restart it and retry this file once.
|
| 379 |
print("[run_rig] load timed out — restarting bpy worker and retrying once", flush=True)
|
| 380 |
ensure_bpy_server_started(force=True)
|
| 381 |
+
dataloader_iter = iter(module.predict_dataloader()[skeleton_cls])
|
| 382 |
for _ in range(i):
|
| 383 |
next(dataloader_iter, None)
|
| 384 |
batch = next(dataloader_iter)
|
|
|
|
| 528 |
outputs,
|
| 529 |
args.model_ckpt,
|
| 530 |
args.hf_path,
|
| 531 |
+
args.skeleton,
|
| 532 |
)
|
| 533 |
|
| 534 |
|
|
|
|
| 550 |
use_postprocess,
|
| 551 |
model_ckpt,
|
| 552 |
hf_path,
|
| 553 |
+
skeleton_cls="articulation",
|
| 554 |
):
|
| 555 |
# Cold workers spend ~30–60 s importing bpy + loading the model before
|
| 556 |
# any GPU work. Give every request a generous 240 s floor.
|
|
|
|
| 571 |
use_postprocess,
|
| 572 |
model_ckpt,
|
| 573 |
hf_path,
|
| 574 |
+
skeleton_cls="articulation",
|
| 575 |
):
|
| 576 |
try:
|
| 577 |
if not files:
|
|
|
|
| 598 |
outputs,
|
| 599 |
model_ckpt,
|
| 600 |
hf_path,
|
| 601 |
+
skeleton_cls,
|
| 602 |
)
|
| 603 |
|
| 604 |
# Collect successfully exported files
|
|
|
|
| 710 |
info="Beam-search width. Larger = higher quality but slower; 1 disables beam search.",
|
| 711 |
)
|
| 712 |
|
| 713 |
+
skeleton_cls = gr.Dropdown(
|
| 714 |
+
choices=SKELETON_CLASSES,
|
| 715 |
+
value="articulation",
|
| 716 |
+
label="Skeleton template",
|
| 717 |
+
info="'mixamo' emits Mixamo bone names (mixamorig:*) so Mixamo animation packs apply directly; 'vroid' emits VRoid/VRM-style humanoid names; 'articulation' is the generic bone_N skeleton.",
|
| 718 |
+
)
|
| 719 |
+
|
| 720 |
gr.Markdown("**Pipeline toggles**")
|
| 721 |
use_skeleton = gr.Checkbox(
|
| 722 |
False,
|
|
|
|
| 765 |
use_postprocess,
|
| 766 |
model_ckpt,
|
| 767 |
hf_path,
|
| 768 |
+
skeleton_cls,
|
| 769 |
],
|
| 770 |
outputs=[log, output],
|
| 771 |
)
|
|
|
|
| 805 |
|
| 806 |
parser.add_argument("--model_ckpt", default=MODEL_CKPTS[0] if MODEL_CKPTS else "")
|
| 807 |
parser.add_argument("--hf_path", default=None)
|
| 808 |
+
parser.add_argument("--skeleton", default="articulation", choices=SKELETON_CLASSES,
|
| 809 |
+
help="Skeleton template: mixamo gives mixamorig:* bone names")
|
| 810 |
|
| 811 |
parser.add_argument("--gradio", action="store_true")
|
| 812 |
|