megalado commited on
Commit
f5cd424
·
1 Parent(s): 20a9eae

use DiP sampler + add HumanML3D stats

Browse files
Files changed (1) hide show
  1. app.py +13 -15
app.py CHANGED
@@ -13,30 +13,28 @@ DEVICE = "cpu" # free HF Spaces have no GPU
13
 
14
 
15
  def generate_motion(prompt: str) -> str:
16
- out_file = Path("/tmp") / f"{uuid.uuid4().hex}.bvh"
 
17
 
18
  cmd = [
19
- "python",
20
- "-m",
21
- "motion_diffusion_model.sample.sample_text2motion",
22
  "--model_path", str(CKPT_PATH),
23
- "--prompt", prompt,
24
- "--output", str(out_file),
25
- "--device", "cpu",
 
 
26
  ]
27
 
28
- # make repo visible to the subprocess
29
  env = os.environ.copy()
30
  root = Path(__file__).parent
31
- repo_inner = root / "motion_diffusion_model"
32
- env["PYTHONPATH"] = f"{env.get('PYTHONPATH', '')}:{root}:{repo_inner}"
33
 
34
- completed = subprocess.run(cmd, env=env, capture_output=True, text=True)
35
- if completed.returncode != 0:
36
- raise RuntimeError(f"Inference failed:\n{completed.stderr}")
37
-
38
- return str(out_file)
39
 
 
 
40
 
41
 
42
 
 
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),
22
+ "--text_prompt", prompt,
23
+ "--cuda", "-1", # -1 => CPU
24
+ "--guidance_param", "7.5",
25
+ "--output_dir", str(out_dir),
26
+ "--num_samples", "1"
27
  ]
28
 
 
29
  env = os.environ.copy()
30
  root = Path(__file__).parent
31
+ repo = root / "motion_diffusion_model"
32
+ env["PYTHONPATH"] = f"{env.get('PYTHONPATH','')}:{root}:{repo}"
33
 
34
+ subprocess.run(cmd, env=env, check=True)
 
 
 
 
35
 
36
+ bvh = next(out_dir.rglob("*.bvh"))
37
+ return str(bvh)
38
 
39
 
40