Spaces:
Running
Running
Push Bot
commited on
Commit
·
de7513c
1
Parent(s):
468c76a
Logos: auto-compose right header logos (camel, tvg, waterloo) from assets into logos/right_logo.png
Browse files- pipeline.py +42 -0
pipeline.py
CHANGED
|
@@ -176,6 +176,39 @@ def _compose_logos_horizontally(logo_paths, out_path: Path, box_w=2000, box_h=47
|
|
| 176 |
print(f" 🧩 Logos composed (width-locked) → {out_path.relative_to(ROOT_DIR)} "
|
| 177 |
f"(n={n}, final_size={canvas_w}x{canvas_h})")
|
| 178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
|
|
@@ -356,6 +389,15 @@ if __name__ == '__main__':
|
|
| 356 |
# 多图:拼接
|
| 357 |
_compose_logos_horizontally(logo_files, left_logo_path, box_w=2000, box_h=476, gap=16)
|
| 358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
print("✅ Step 3 done.")
|
| 360 |
except Exception as e:
|
| 361 |
print(f"❌ Step 3 failed: {e}")
|
|
|
|
| 176 |
print(f" 🧩 Logos composed (width-locked) → {out_path.relative_to(ROOT_DIR)} "
|
| 177 |
f"(n={n}, final_size={canvas_w}x{canvas_h})")
|
| 178 |
|
| 179 |
+
def _find_right_logos_candidates(root_dir: Path):
|
| 180 |
+
"""Find candidate logos for right header in order: camel-ai, tvg, waterloo.
|
| 181 |
+
Search common assets locations; match by filename substring (case-insensitive).
|
| 182 |
+
"""
|
| 183 |
+
cand_dirs = [
|
| 184 |
+
root_dir / "assets",
|
| 185 |
+
root_dir / "assets" / "logos",
|
| 186 |
+
root_dir / "Paper2Poster" / "assets",
|
| 187 |
+
root_dir / "Paper2Poster" / "assets" / "logos",
|
| 188 |
+
root_dir / "template" / "logos",
|
| 189 |
+
]
|
| 190 |
+
imgs = []
|
| 191 |
+
for d in cand_dirs:
|
| 192 |
+
if d.exists():
|
| 193 |
+
for p in d.iterdir():
|
| 194 |
+
if p.is_file() and p.suffix.lower() in {".png", ".jpg", ".jpeg", ".webp", ".bmp"}:
|
| 195 |
+
imgs.append(p)
|
| 196 |
+
|
| 197 |
+
def pick(sub):
|
| 198 |
+
for p in imgs:
|
| 199 |
+
if sub in p.name.lower():
|
| 200 |
+
return p
|
| 201 |
+
return None
|
| 202 |
+
|
| 203 |
+
picks = []
|
| 204 |
+
for key in ("camel", "tvg", "waterloo"):
|
| 205 |
+
p = pick(key)
|
| 206 |
+
if p:
|
| 207 |
+
picks.append(p)
|
| 208 |
+
if not picks and imgs:
|
| 209 |
+
picks = imgs[:3]
|
| 210 |
+
return picks
|
| 211 |
+
|
| 212 |
|
| 213 |
|
| 214 |
|
|
|
|
| 389 |
# 多图:拼接
|
| 390 |
_compose_logos_horizontally(logo_files, left_logo_path, box_w=2000, box_h=476, gap=16)
|
| 391 |
|
| 392 |
+
# Compose right header logos (camel-ai, tvg, waterloo) if available under assets
|
| 393 |
+
try:
|
| 394 |
+
right_candidates = _find_right_logos_candidates(ROOT_DIR)
|
| 395 |
+
if right_candidates:
|
| 396 |
+
right_logo_path = logos_out_dir / "right_logo.png"
|
| 397 |
+
_compose_logos_horizontally(right_candidates, right_logo_path, box_w=2000, box_h=476, gap=24)
|
| 398 |
+
except Exception as e:
|
| 399 |
+
print(f"⚠️ Right-logo composition skipped: {e}")
|
| 400 |
+
|
| 401 |
print("✅ Step 3 done.")
|
| 402 |
except Exception as e:
|
| 403 |
print(f"❌ Step 3 failed: {e}")
|