megalado
run demo.py via file path, not -m
f14e8c5
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()