Spaces:
Sleeping
Sleeping
megalado
commited on
Commit
·
5c02fe8
1
Parent(s):
f6303c9
use DiP sampler + add HumanML3D stats
Browse files
app.py
CHANGED
|
@@ -11,11 +11,10 @@ CKPT_PATH = "checkpoints/t2m_50step.pt" # make sure this file exists
|
|
| 11 |
DEVICE = "cpu" # free HF Spaces have no GPU
|
| 12 |
# ---------------------------------------------------------------------
|
| 13 |
|
| 14 |
-
|
| 15 |
def generate_motion(prompt: str) -> str:
|
| 16 |
out_dir = Path("/tmp") / f"mdm_{uuid.uuid4().hex}"
|
| 17 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 18 |
-
|
| 19 |
cmd = [
|
| 20 |
"python", "-m", "motion_diffusion_model.sample.generate",
|
| 21 |
"--model_path", str(CKPT_PATH),
|
|
@@ -24,21 +23,23 @@ def generate_motion(prompt: str) -> str:
|
|
| 24 |
"--guidance_param", "7.5",
|
| 25 |
"--output_dir", str(out_dir),
|
| 26 |
"--num_samples", "1",
|
| 27 |
-
"--unconstrained"
|
|
|
|
| 28 |
]
|
| 29 |
-
|
| 30 |
-
|
| 31 |
env = os.environ.copy()
|
| 32 |
root = Path(__file__).parent
|
| 33 |
repo = root / "motion_diffusion_model"
|
| 34 |
env["PYTHONPATH"] = f"{env.get('PYTHONPATH','')}:{root}:{repo}"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# ----------------------- Gradio UI ----------------------------------
|
| 44 |
iface = gr.Interface(
|
|
@@ -56,4 +57,4 @@ iface = gr.Interface(
|
|
| 56 |
)
|
| 57 |
|
| 58 |
if __name__ == "__main__":
|
| 59 |
-
iface.launch()
|
|
|
|
| 11 |
DEVICE = "cpu" # free HF Spaces have no GPU
|
| 12 |
# ---------------------------------------------------------------------
|
| 13 |
|
|
|
|
| 14 |
def generate_motion(prompt: str) -> str:
|
| 15 |
out_dir = Path("/tmp") / f"mdm_{uuid.uuid4().hex}"
|
| 16 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 17 |
+
|
| 18 |
cmd = [
|
| 19 |
"python", "-m", "motion_diffusion_model.sample.generate",
|
| 20 |
"--model_path", str(CKPT_PATH),
|
|
|
|
| 23 |
"--guidance_param", "7.5",
|
| 24 |
"--output_dir", str(out_dir),
|
| 25 |
"--num_samples", "1",
|
| 26 |
+
"--unconstrained",
|
| 27 |
+
"--inference_only" # Add this flag (you'll need to implement it)
|
| 28 |
]
|
| 29 |
+
|
|
|
|
| 30 |
env = os.environ.copy()
|
| 31 |
root = Path(__file__).parent
|
| 32 |
repo = root / "motion_diffusion_model"
|
| 33 |
env["PYTHONPATH"] = f"{env.get('PYTHONPATH','')}:{root}:{repo}"
|
| 34 |
+
|
| 35 |
+
try:
|
| 36 |
+
subprocess.run(cmd, env=env, check=True)
|
| 37 |
+
bvh = next(out_dir.rglob("*.bvh"))
|
| 38 |
+
return str(bvh)
|
| 39 |
+
except subprocess.CalledProcessError as e:
|
| 40 |
+
return f"Error generating motion: {str(e)}"
|
| 41 |
+
except StopIteration:
|
| 42 |
+
return "No BVH file was generated."
|
| 43 |
|
| 44 |
# ----------------------- Gradio UI ----------------------------------
|
| 45 |
iface = gr.Interface(
|
|
|
|
| 57 |
)
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
+
iface.launch()
|