Spaces:
Running
on
Zero
Running
on
Zero
jake
commited on
Commit
ยท
c32f7bb
1
Parent(s):
82bd956
TF
Browse files- MMaDA/inference/gradio_multimodal_demo_inst.py +0 -27
- app.py +26 -0
MMaDA/inference/gradio_multimodal_demo_inst.py
CHANGED
|
@@ -467,33 +467,6 @@ def _load_t2i_examples():
|
|
| 467 |
return [[line] for line in lines]
|
| 468 |
|
| 469 |
|
| 470 |
-
def _load_i2i_examples():
|
| 471 |
-
d = ASSET_ROOT / "i2i"
|
| 472 |
-
if not d.exists():
|
| 473 |
-
return []
|
| 474 |
-
|
| 475 |
-
# ์ด๋ฏธ์ง ํ์ผ๋ค (image1.jpeg, image2.png, ...)
|
| 476 |
-
image_files = sorted(
|
| 477 |
-
[p for p in d.iterdir() if p.suffix.lower() in {".png", ".jpg", ".jpeg", ".webp"}]
|
| 478 |
-
)
|
| 479 |
-
# ํ
์คํธ ํ์ผ๋ค (text1.txt, text2.txt, ...)
|
| 480 |
-
text_files = sorted(
|
| 481 |
-
[p for p in d.iterdir() if p.suffix.lower() == ".txt"]
|
| 482 |
-
)
|
| 483 |
-
|
| 484 |
-
n = min(len(image_files), len(text_files))
|
| 485 |
-
examples = []
|
| 486 |
-
for i in range(n):
|
| 487 |
-
img_path = image_files[i]
|
| 488 |
-
txt_path = text_files[i]
|
| 489 |
-
instruction = txt_path.read_text(encoding="utf-8").strip()
|
| 490 |
-
if not instruction:
|
| 491 |
-
continue
|
| 492 |
-
# Gradio Examples ํ์: [image, instruction_text]
|
| 493 |
-
examples.append([str(img_path), instruction])
|
| 494 |
-
return examples
|
| 495 |
-
|
| 496 |
-
|
| 497 |
def _load_media_examples(subdir: str, suffixes):
|
| 498 |
target_dir = DEMO_ROOT / subdir
|
| 499 |
if not target_dir.exists():
|
|
|
|
| 467 |
return [[line] for line in lines]
|
| 468 |
|
| 469 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
def _load_media_examples(subdir: str, suffixes):
|
| 471 |
target_dir = DEMO_ROOT / subdir
|
| 472 |
if not target_dir.exists():
|
app.py
CHANGED
|
@@ -182,11 +182,37 @@ def _load_media_examples(subdir: str, suffixes):
|
|
| 182 |
ex.append([str(p)])
|
| 183 |
return ex
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
# text-based examples
|
| 187 |
T2S_EXAMPLES = _load_text_examples(ASSET_ROOT / "t2s" / "text.txt")
|
| 188 |
CHAT_EXAMPLES = _load_text_examples(ASSET_ROOT / "chat" / "text.txt")
|
| 189 |
T2I_EXAMPLES = _load_text_examples(ASSET_ROOT / "t2i" / "text.txt")
|
|
|
|
| 190 |
|
| 191 |
# audio / video / image examples
|
| 192 |
S2T_EXAMPLES = _load_media_examples("s2t", {".wav", ".mp3", ".flac", ".ogg"})
|
|
|
|
| 182 |
ex.append([str(p)])
|
| 183 |
return ex
|
| 184 |
|
| 185 |
+
def _load_i2i_examples():
|
| 186 |
+
d = ASSET_ROOT / "i2i"
|
| 187 |
+
if not d.exists():
|
| 188 |
+
return []
|
| 189 |
+
|
| 190 |
+
# ์ด๋ฏธ์ง ํ์ผ๋ค (image1.jpeg, image2.png, ...)
|
| 191 |
+
image_files = sorted(
|
| 192 |
+
[p for p in d.iterdir() if p.suffix.lower() in {".png", ".jpg", ".jpeg", ".webp"}]
|
| 193 |
+
)
|
| 194 |
+
# ํ
์คํธ ํ์ผ๋ค (text1.txt, text2.txt, ...)
|
| 195 |
+
text_files = sorted(
|
| 196 |
+
[p for p in d.iterdir() if p.suffix.lower() == ".txt"]
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
n = min(len(image_files), len(text_files))
|
| 200 |
+
examples = []
|
| 201 |
+
for i in range(n):
|
| 202 |
+
img_path = image_files[i]
|
| 203 |
+
txt_path = text_files[i]
|
| 204 |
+
instruction = txt_path.read_text(encoding="utf-8").strip()
|
| 205 |
+
if not instruction:
|
| 206 |
+
continue
|
| 207 |
+
# Gradio Examples ํ์: [image, instruction_text]
|
| 208 |
+
examples.append([str(img_path), instruction])
|
| 209 |
+
return examples
|
| 210 |
|
| 211 |
# text-based examples
|
| 212 |
T2S_EXAMPLES = _load_text_examples(ASSET_ROOT / "t2s" / "text.txt")
|
| 213 |
CHAT_EXAMPLES = _load_text_examples(ASSET_ROOT / "chat" / "text.txt")
|
| 214 |
T2I_EXAMPLES = _load_text_examples(ASSET_ROOT / "t2i" / "text.txt")
|
| 215 |
+
I2I_EXAMPLES = _load_i2i_examples()
|
| 216 |
|
| 217 |
# audio / video / image examples
|
| 218 |
S2T_EXAMPLES = _load_media_examples("s2t", {".wav", ".mp3", ".flac", ".ogg"})
|