Tharun156 commited on
Commit
54da83d
Β·
verified Β·
1 Parent(s): 589daca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -63
app.py CHANGED
@@ -1,63 +0,0 @@
1
- import os
2
- import shutil
3
- import sys
4
- from pathlib import Path
5
-
6
- from huggingface_hub import snapshot_download
7
-
8
- # ---------------------------------------------------------------------------
9
- # Optional: pull checkpoints and auxiliary assets at startup. Set the
10
- # HF_GESTURELSM_WEIGHTS_REPO environment variable in the Space settings to the
11
- # dataset or model repo that hosts the pre-trained weights (e.g. "username/gesturelsm-assets").
12
- # Files will be placed under ckpt/ so the existing config paths keep working.
13
- # ---------------------------------------------------------------------------
14
- BASE_DIR = Path(__file__).parent.resolve()
15
- ROOT_DIR = BASE_DIR.parent.resolve()
16
-
17
- # Ensure project root is on sys.path so intra-repo imports (e.g. `optimizers`) work.
18
- if str(ROOT_DIR) not in sys.path:
19
- sys.path.insert(0, str(ROOT_DIR))
20
-
21
- # Quick sanity check in Space logs to confirm the repo root is visible at runtime.
22
- print("[GestureLSM] sys.path:")
23
- for entry in sys.path:
24
- print(" ", entry)
25
- CKPT_DIR = BASE_DIR / "ckpt"
26
- CKPT_DIR.mkdir(parents=True, exist_ok=True)
27
-
28
- weights_repo = os.environ.get("HF_GESTURELSM_WEIGHTS_REPO", "").strip()
29
- if weights_repo:
30
- snapshot_download(
31
- repo_id=weights_repo,
32
- repo_type="dataset",
33
- local_dir=CKPT_DIR,
34
- local_dir_use_symlinks=False,
35
- allow_patterns=["*.pth", "*.bin", "*.npz", "*.npy"],
36
- )
37
-
38
- # Ensure expected runtime directories exist so the demo can write outputs.
39
- datasets_hub_dir = BASE_DIR / "datasets" / "hub"
40
- for relative in ["outputs/audio2pose", "datasets/BEAT_SMPL", "datasets/hub"]:
41
- (BASE_DIR / relative).mkdir(parents=True, exist_ok=True)
42
-
43
- smplx_dest = datasets_hub_dir / "smplx_models"
44
- smplx_dest.mkdir(parents=True, exist_ok=True)
45
-
46
- if not any(smplx_dest.iterdir()):
47
- smplx_sources = list(CKPT_DIR.glob("**/smplx_models"))
48
- if smplx_sources:
49
- smplx_source = smplx_sources[0]
50
- for item in smplx_source.iterdir():
51
- target = smplx_dest / item.name
52
- if item.is_dir():
53
- shutil.copytree(item, target, dirs_exist_ok=True)
54
- else:
55
- shutil.copy2(item, target)
56
- else:
57
- print("[GestureLSM] WARNING: smplx_models directory missing; ensure the weights repo contains it.")
58
-
59
- # Reuse the existing Gradio interface defined in demo.py.
60
- from demo import demo as gesture_demo # noqa: E402
61
-
62
- if __name__ == "__main__":
63
- gesture_demo.queue(concurrency_count=1).launch(server_name="0.0.0.0", share=False)