Spaces:
Sleeping
Sleeping
Youngsun Lim commited on
Commit ยท
45f5616
1
Parent(s): fcb4dbb
2nd page error
Browse files
app.py
CHANGED
|
@@ -18,22 +18,28 @@ TOP_DIRS = [
|
|
| 18 |
"Wan2.2",
|
| 19 |
"wan21_videos",
|
| 20 |
]
|
| 21 |
-
|
| 22 |
def _choose_prefix_from_filename(base: str) -> str:
|
| 23 |
"""
|
| 24 |
-
base
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
"""
|
|
|
|
| 29 |
for d in TOP_DIRS:
|
| 30 |
-
# ์ผ
|
| 31 |
-
if base.startswith(d + "_"):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
if "_" in base:
|
| 38 |
return base.split("_")[0]
|
| 39 |
return os.path.splitext(base)[0]
|
|
@@ -43,25 +49,19 @@ def _candidate_relpaths(url_or_name: str):
|
|
| 43 |
# ํ์ผ๋ช
๋ง ๋ฝ๊ณ ๊ณต๋ฐฑ/๊ฐํ ์ ๊ฑฐ
|
| 44 |
base = os.path.basename(url_or_name).strip()
|
| 45 |
|
| 46 |
-
# prefix ๊ฒฐ์ : ์ค์ repo ์์ ํด๋ ์ด๋ฆ๊ณผ ๋ง์ถฐ์ฃผ๊ธฐ
|
| 47 |
prefix = _choose_prefix_from_filename(base)
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
#
|
| 51 |
-
#
|
| 52 |
-
# Opensora_768
|
| 53 |
-
#
|
| 54 |
-
#
|
| 55 |
-
#
|
| 56 |
-
# ๋๊ฐ Opensora_768 ์ชฝ ์ค์ท์ ์์ง ์๋ณด์ฌ์คฌ์ง๋ง,
|
| 57 |
-
# ์ง๊ธ ์๋ฌ์์ ์ฐ๋ฆฌ๋ <prefix>/<prefix>/<file>์ ์๋ ์ ํด์ ์ฃฝ์ ๊ฒ ์๋๊ณ
|
| 58 |
-
# prefix ์์ฒด๊ฐ ํ๋ ค์ ์ฃฝ์๊ฑฐ๋ผ ๋ ๋ค ์๋ํด๋ ์์ ํด.
|
| 59 |
-
|
| 60 |
alt_prefix_videos = (
|
| 61 |
prefix if prefix.endswith("_videos") else (prefix + "_videos")
|
| 62 |
)
|
| 63 |
|
| 64 |
-
# ์ต์ข
์ ์ผ๋ก ๊ฐ๋ฅํ ๋ชจ๋ ํจํด์ ๋ค ์๋
|
| 65 |
candidates = [
|
| 66 |
f"video_examples/{prefix}/{prefix}/{base}",
|
| 67 |
f"video_examples/{prefix}/{alt_prefix_videos}/{base}",
|
|
@@ -77,6 +77,7 @@ def _candidate_relpaths(url_or_name: str):
|
|
| 77 |
return uniq
|
| 78 |
|
| 79 |
|
|
|
|
| 80 |
@lru_cache(maxsize=2048)
|
| 81 |
def get_local_video_path(hf_url_or_relpath: str) -> str:
|
| 82 |
# if already local, just ensure it's muted
|
|
|
|
| 18 |
"Wan2.2",
|
| 19 |
"wan21_videos",
|
| 20 |
]
|
|
|
|
| 21 |
def _choose_prefix_from_filename(base: str) -> str:
|
| 22 |
"""
|
| 23 |
+
base ์:
|
| 24 |
+
'wan21_videos_BodyWeightSquats_06_10c02b51.mp4'
|
| 25 |
+
'Wan2.2_BodyWeightSquats_03_g09_c02.mp4'
|
| 26 |
+
'Opensora_768_PushUps_03_124bba2d.mp4'
|
| 27 |
+
|
| 28 |
+
๋ฆฌํฌ์ ์ค์ ์์ ํด๋๋ช
(TOP_DIRS) ์ค
|
| 29 |
+
ํ์ผ๋ช
์ด ๊ทธ ํด๋๋ช
์ผ๋ก ์์ํ๋ฉด ๊ทธ๊ฑธ prefix๋ก ์ด๋ค.
|
| 30 |
+
๊ฐ์ฅ ๊ธด ๋งค์นญ์ ์ฐ์ ์ผ๋ก ํ๋ค.
|
| 31 |
"""
|
| 32 |
+
best = None
|
| 33 |
for d in TOP_DIRS:
|
| 34 |
+
# ์ ์ผ ํํ ํจํด์ "<dir>_" ๋ก ์์ํ๋ ๊ฑฐ๋ผ์ ์ด๊ฑธ ๋จผ์ ๋ณธ๋ค
|
| 35 |
+
if base.startswith(d + "_") or base.startswith(d + "/") or base.startswith(d + "-") or base.startswith(d):
|
| 36 |
+
if best is None or len(d) > len(best):
|
| 37 |
+
best = d
|
| 38 |
+
|
| 39 |
+
if best is not None:
|
| 40 |
+
return best
|
| 41 |
+
|
| 42 |
+
# fallback (๊ฑฐ์ ์ ํ์ผ ์ ์)
|
| 43 |
if "_" in base:
|
| 44 |
return base.split("_")[0]
|
| 45 |
return os.path.splitext(base)[0]
|
|
|
|
| 49 |
# ํ์ผ๋ช
๋ง ๋ฝ๊ณ ๊ณต๋ฐฑ/๊ฐํ ์ ๊ฑฐ
|
| 50 |
base = os.path.basename(url_or_name).strip()
|
| 51 |
|
|
|
|
| 52 |
prefix = _choose_prefix_from_filename(base)
|
| 53 |
|
| 54 |
+
# ์:
|
| 55 |
+
# video_examples/Wan2.2/Wan2.2/Wan2.2_BodyWeightSquats_03_....mp4
|
| 56 |
+
# video_examples/Hunyuan_videos/Hunyuan_videos/Hunyuan_videos_....mp4
|
| 57 |
+
# video_examples/Opensora_768/Opensora_768/...mp4 ๋๋
|
| 58 |
+
# video_examples/Opensora_768/...mp4 (๋ ๋ค ๊ฐ๋ฅ์ฑ)
|
| 59 |
+
#
|
| 60 |
+
# ๊ทธ๋์ ์ฌ๋ฌ ํจํด์ ๋ค ์๋ํด๋ณธ๋ค.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
alt_prefix_videos = (
|
| 62 |
prefix if prefix.endswith("_videos") else (prefix + "_videos")
|
| 63 |
)
|
| 64 |
|
|
|
|
| 65 |
candidates = [
|
| 66 |
f"video_examples/{prefix}/{prefix}/{base}",
|
| 67 |
f"video_examples/{prefix}/{alt_prefix_videos}/{base}",
|
|
|
|
| 77 |
return uniq
|
| 78 |
|
| 79 |
|
| 80 |
+
|
| 81 |
@lru_cache(maxsize=2048)
|
| 82 |
def get_local_video_path(hf_url_or_relpath: str) -> str:
|
| 83 |
# if already local, just ensure it's muted
|