Spaces:
Runtime error
Runtime error
megalado commited on
Commit ·
e8a6a9b
1
Parent(s): 0730af4
Initial MLD text→motion Space
Browse files- app.py +58 -0
- checkpoints/mld_humanml.pt +3 -0
- motion_latent_diffusion +1 -0
- requirements.txt +16 -0
app.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
import uuid
|
| 3 |
+
import os
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
# ──────────────────────────────────────────────────────────────
|
| 8 |
+
# CONFIG
|
| 9 |
+
# ──────────────────────────────────────────────────────────────
|
| 10 |
+
CKPT = "checkpoints/mld_humanml.pt" # <— make sure this file exists
|
| 11 |
+
DEVICE = "cpu" # free HF Spaces = CPU only
|
| 12 |
+
STEPS = "50" # diffusion steps (≈60 s on CPU)
|
| 13 |
+
# ──────────────────────────────────────────────────────────────
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def generate_motion(prompt: str) -> str:
|
| 17 |
+
"""
|
| 18 |
+
Call the MLD text-to-motion sampler and return a BVH path for Gradio.
|
| 19 |
+
"""
|
| 20 |
+
# unique temp-file to hold the BVH
|
| 21 |
+
out_bvh = Path("/tmp") / f"{uuid.uuid4().hex}.bvh"
|
| 22 |
+
|
| 23 |
+
cmd = [
|
| 24 |
+
"python",
|
| 25 |
+
"-m", "motion_latent_diffusion.mld.sample.text2motion", # ← sampler module
|
| 26 |
+
"--checkpoint", CKPT,
|
| 27 |
+
"--prompt", prompt,
|
| 28 |
+
"--device", DEVICE,
|
| 29 |
+
"--output", str(out_bvh),
|
| 30 |
+
"--steps", STEPS
|
| 31 |
+
]
|
| 32 |
+
|
| 33 |
+
# make sure Python can import motion_latent_diffusion.*
|
| 34 |
+
env = os.environ.copy()
|
| 35 |
+
repo_root = Path(__file__).parent
|
| 36 |
+
env["PYTHONPATH"] = f"{env.get('PYTHONPATH', '')}:{repo_root}"
|
| 37 |
+
|
| 38 |
+
# run the sampler
|
| 39 |
+
subprocess.run(cmd, env=env, check=True)
|
| 40 |
+
|
| 41 |
+
return str(out_bvh)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# ────────────────── Gradio UI ───────────────────────────────
|
| 45 |
+
iface = gr.Interface(
|
| 46 |
+
fn=generate_motion,
|
| 47 |
+
inputs=gr.Textbox(
|
| 48 |
+
lines=2,
|
| 49 |
+
placeholder="e.g. a person walks forward and waves",
|
| 50 |
+
label="Text Prompt"
|
| 51 |
+
),
|
| 52 |
+
outputs=gr.File(label="Download BVH"),
|
| 53 |
+
title="Motion-Latent-Diffusion – Text → 3D Motion",
|
| 54 |
+
description="Enter a natural-language prompt and get a 3-second BVH animation (CPU demo)."
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
if __name__ == "__main__":
|
| 58 |
+
iface.launch()
|
checkpoints/mld_humanml.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cdb21d78905fcaa41212f85b3fe13fa342f84ccbad5f90b9a7251b217134ecc4
|
| 3 |
+
size 1652
|
motion_latent_diffusion
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit 081ce3152e5a95b14a4495fb2d32939c257c6216
|
requirements.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate>=0.16.0
|
| 2 |
+
configargparse>=1.5.3
|
| 3 |
+
einops>=0.6.0
|
| 4 |
+
gradio>=3.32.0
|
| 5 |
+
h5py>=3.8.0
|
| 6 |
+
huggingface-hub>=0.14.1
|
| 7 |
+
hydra-core>=1.3.2
|
| 8 |
+
matplotlib>=3.7.1
|
| 9 |
+
numpy>=1.24.3
|
| 10 |
+
omegaconf>=2.3.0
|
| 11 |
+
safetensors>=0.3.1
|
| 12 |
+
scipy>=1.10.1
|
| 13 |
+
tensorboard>=2.12.3
|
| 14 |
+
torch>=2.0.0
|
| 15 |
+
tqdm>=4.65.0
|
| 16 |
+
transformers>=4.28.1
|