Tharun156 commited on
Commit
7f79678
Β·
verified Β·
1 Parent(s): fae86e5

Update hf_space/app.py

Browse files
Files changed (1) hide show
  1. hf_space/app.py +32 -4
hf_space/app.py CHANGED
@@ -26,6 +26,12 @@ for entry in sys.path:
26
  print(" ", entry)
27
  ASSET_CACHE_DIR = BASE_DIR / "asset_cache"
28
  ASSET_CACHE_DIR.mkdir(parents=True, exist_ok=True)
 
 
 
 
 
 
29
 
30
  weights_repo = os.environ.get("HF_GESTURELSM_WEIGHTS_REPO", "").strip()
31
  if weights_repo:
@@ -67,6 +73,25 @@ def _sync_downloaded_assets(download_root: Path) -> None:
67
 
68
  anchor_dirs = {"ckpt", "mean_std", "datasets", "weights", "hf_assets"}
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  copied = 0
71
  skipped = 0
72
  for file_path in download_root.rglob("*"):
@@ -77,10 +102,13 @@ def _sync_downloaded_assets(download_root: Path) -> None:
77
  relative = file_path.relative_to(download_root)
78
  parts = relative.parts
79
  anchor_index = next((idx for idx, part in enumerate(parts) if part in anchor_dirs), None)
80
- if anchor_index is None:
81
- skipped += 1
82
- continue
83
- destination = ROOT_DIR / Path(*parts[anchor_index:])
 
 
 
84
  destination.parent.mkdir(parents=True, exist_ok=True)
85
  try:
86
  shutil.copy2(file_path, destination)
 
26
  print(" ", entry)
27
  ASSET_CACHE_DIR = BASE_DIR / "asset_cache"
28
  ASSET_CACHE_DIR.mkdir(parents=True, exist_ok=True)
29
+ CKPT_DIR = ROOT_DIR / "ckpt"
30
+ CKPT_DIR.mkdir(parents=True, exist_ok=True)
31
+ MEAN_STD_DIR = ROOT_DIR / "mean_std"
32
+ MEAN_STD_DIR.mkdir(parents=True, exist_ok=True)
33
+ WEIGHTS_DIR = ROOT_DIR / "weights"
34
+ WEIGHTS_DIR.mkdir(parents=True, exist_ok=True)
35
 
36
  weights_repo = os.environ.get("HF_GESTURELSM_WEIGHTS_REPO", "").strip()
37
  if weights_repo:
 
73
 
74
  anchor_dirs = {"ckpt", "mean_std", "datasets", "weights", "hf_assets"}
75
 
76
+ fallback_destinations = {
77
+ "net_300000_upper.pth": CKPT_DIR / "net_300000_upper.pth",
78
+ "net_300000_lower.pth": CKPT_DIR / "net_300000_lower.pth",
79
+ "net_300000_face.pth": CKPT_DIR / "net_300000_face.pth",
80
+ "net_300000_hands.pth": CKPT_DIR / "net_300000_hands.pth",
81
+ "net_300000_lower_trans.pth": CKPT_DIR / "net_300000_lower_trans.pth",
82
+ "face_all_speakers.pth": CKPT_DIR / "face_all_speakers.pth",
83
+ "hand_all_speakers.pth": CKPT_DIR / "hand_all_speakers.pth",
84
+ "lower_all_speakers.pth": CKPT_DIR / "lower_all_speakers.pth",
85
+ "upper_all_speakers.pth": CKPT_DIR / "upper_all_speakers.pth",
86
+ "meanflow.pth": CKPT_DIR / "meanflow.pth",
87
+ "new_540_shortcut.bin": CKPT_DIR / "new_540_shortcut.bin",
88
+ "beatx_2_330_mean.npy": MEAN_STD_DIR / "beatx_2_330_mean.npy",
89
+ "beatx_2_330_std.npy": MEAN_STD_DIR / "beatx_2_330_std.npy",
90
+ "beatx_2_trans_mean.npy": MEAN_STD_DIR / "beatx_2_trans_mean.npy",
91
+ "beatx_2_trans_std.npy": MEAN_STD_DIR / "beatx_2_trans_std.npy",
92
+ "AESKConv_240_100.bin": WEIGHTS_DIR / "AESKConv_240_100.bin",
93
+ }
94
+
95
  copied = 0
96
  skipped = 0
97
  for file_path in download_root.rglob("*"):
 
102
  relative = file_path.relative_to(download_root)
103
  parts = relative.parts
104
  anchor_index = next((idx for idx, part in enumerate(parts) if part in anchor_dirs), None)
105
+ if anchor_index is not None:
106
+ destination = ROOT_DIR / Path(*parts[anchor_index:])
107
+ else:
108
+ destination = fallback_destinations.get(file_path.name)
109
+ if destination is None:
110
+ skipped += 1
111
+ continue
112
  destination.parent.mkdir(parents=True, exist_ok=True)
113
  try:
114
  shutil.copy2(file_path, destination)