Spaces:
Runtime error
Runtime error
| import subprocess, uuid, os | |
| from pathlib import Path | |
| import gradio as gr | |
| # ββ paths βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| CKPT = "checkpoints/mld_humanml.pt" # your 90 MB weight | |
| DEVICE = "cpu" # free HF Spaces | |
| STEPS = "50" # diffusion steps | |
| CFG = "configs/config_mld_humanml3d.yaml" # default config file | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def generate_motion(prompt: str) -> str: | |
| out_bvh = Path("/tmp") / f"{uuid.uuid4().hex}.bvh" | |
| cmd = [ | |
| "python", | |
| "-m", "motion_latent_diffusion/demo.py", # β new: run demo.py | |
| "--cfg", CFG, | |
| "--checkpoint", CKPT, | |
| "--prompt", prompt, | |
| "--device", DEVICE, | |
| "--steps", STEPS, | |
| "--output", str(out_bvh) | |
| ] | |
| # make repo importable | |
| env = os.environ.copy() | |
| root = Path(__file__).parent | |
| env["PYTHONPATH"] = f"{env.get('PYTHONPATH','')}:{root}" | |
| subprocess.run(cmd, env=env, check=True) | |
| return str(out_bvh) | |
| # ββ Gradio UI βββββββββββββββββββββββββββββββββββββββββββββββββ | |
| iface = gr.Interface( | |
| fn=generate_motion, | |
| inputs=gr.Textbox(lines=2, placeholder="e.g. a person walks and waves"), | |
| outputs=gr.File(label="Download BVH"), | |
| title="Motion-Latent-Diffusion β Text β BVH (CPU demo)", | |
| description="Enter a prompt to generate a 3-second motion clip." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() | |