Spaces:
Sleeping
Sleeping
Youngsun Lim
commited on
Commit
ยท
fcb4dbb
1
Parent(s):
7939802
2nd page error
Browse files
app.py
CHANGED
|
@@ -11,27 +11,71 @@ import secrets, time, string
|
|
| 11 |
from functools import lru_cache
|
| 12 |
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
def _candidate_relpaths(url_or_name: str):
|
| 15 |
-
#
|
| 16 |
base = os.path.basename(url_or_name).strip()
|
| 17 |
|
| 18 |
-
# prefix
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
| 29 |
f"video_examples/{prefix}/{prefix}/{base}",
|
| 30 |
f"video_examples/{prefix}/{alt_prefix_videos}/{base}",
|
| 31 |
f"video_examples/{prefix}/{base}",
|
| 32 |
f"video_examples/{base}",
|
| 33 |
]
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
@lru_cache(maxsize=2048)
|
| 37 |
def get_local_video_path(hf_url_or_relpath: str) -> str:
|
|
|
|
| 11 |
from functools import lru_cache
|
| 12 |
|
| 13 |
|
| 14 |
+
TOP_DIRS = [
|
| 15 |
+
"Hunyuan_videos",
|
| 16 |
+
"Opensora_768",
|
| 17 |
+
"RunwayGen4",
|
| 18 |
+
"Wan2.2",
|
| 19 |
+
"wan21_videos",
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
def _choose_prefix_from_filename(base: str) -> str:
|
| 23 |
+
"""
|
| 24 |
+
base = 'Opensora_768_PushUps_03_124bba2d.mp4' ๊ฐ์ ์ค์ ํ์ผ ์ด๋ฆ.
|
| 25 |
+
์์์ ์ ์ํ top-level ๋๋ ํ ๋ฆฌ ํ๋ณด๋ค ์ค
|
| 26 |
+
base๊ฐ "<dir>_" ํน์ "<dir>-" ํน์ "<dir>." ๋ก ์์ํ๋ฉด ๊ทธ๊ฑธ prefix๋ก ์ฑํ.
|
| 27 |
+
(์ค์ ๋ก๋ '_' ํจํด์ด๋ฉด ์ถฉ๋ถํ ๊ฐ๋ฅ์ฑ์ด ํผ)
|
| 28 |
+
"""
|
| 29 |
+
for d in TOP_DIRS:
|
| 30 |
+
# ์ผ๋ฐ์ ์ผ๋ก "<dir>_" ๋ก ์์ํจ
|
| 31 |
+
if base.startswith(d + "_"):
|
| 32 |
+
return d
|
| 33 |
+
# ํน์ ๊ทธ๋ฅ ์ ํํ ๊ฐ์ ์ด๋ฆ๋ง ์์ ์๋ ์์ผ๋๊น(์์ ์ฅ์น)
|
| 34 |
+
if base.startswith(d):
|
| 35 |
+
return d
|
| 36 |
+
# fallback: ์ด์ ๋จ์ ๋ก์ง (ํ ๋ฒ๋ ๋ชป ๋ง์ท์ ๋ ๋๋น)
|
| 37 |
+
if "_" in base:
|
| 38 |
+
return base.split("_")[0]
|
| 39 |
+
return os.path.splitext(base)[0]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
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 |
+
# ์ผ๋ถ ๋ชจ๋ธ(Hunyuan_videos, Wan2.2 ๋ฑ)์
|
| 50 |
+
# video_examples/<prefix>/<prefix>/<file.mp4>
|
| 51 |
+
# ์ด๋ฐ ๊ตฌ์กฐ(2๋จ๊ณ ์ค์ฒฉ)
|
| 52 |
+
# Opensora_768๋ ์ค์ ๋ก ๋ณด๋ฉด?
|
| 53 |
+
# video_examples/Opensora_768/Opensora_768/ํ์ผ.mp4 ์ธ์ง
|
| 54 |
+
# video_examples/Opensora_768/ํ์ผ.mp4 ์ธ์ง ํ์ธ ํ์.
|
| 55 |
+
# ๋ฐฉ๊ธ Wan2.2 ์ค์ท์ 2๋จ๊ณ ์ค์ฒฉ (Wan2.2/Wan2.2/ํ์ผ).
|
| 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}",
|
| 68 |
f"video_examples/{prefix}/{base}",
|
| 69 |
f"video_examples/{base}",
|
| 70 |
]
|
| 71 |
|
| 72 |
+
# ์ค๋ณต ์ ๊ฑฐ
|
| 73 |
+
uniq = []
|
| 74 |
+
for c in candidates:
|
| 75 |
+
if c not in uniq:
|
| 76 |
+
uniq.append(c)
|
| 77 |
+
return uniq
|
| 78 |
+
|
| 79 |
|
| 80 |
@lru_cache(maxsize=2048)
|
| 81 |
def get_local_video_path(hf_url_or_relpath: str) -> str:
|