Spaces:
Sleeping
Sleeping
Update pipeline.py
Browse files- pipeline.py +12 -5
pipeline.py
CHANGED
|
@@ -43,20 +43,26 @@ def safe_copy(src: Path, dst: Path):
|
|
| 43 |
def str2list(s):
|
| 44 |
return [int(x) for x in s.split(',')]
|
| 45 |
|
| 46 |
-
def run_paper2poster_content_build():
|
| 47 |
print("🧩 Step 1.5: Preparing Paper2Poster inputs & generating poster contents ...")
|
| 48 |
|
| 49 |
src_pdf = ROOT_DIR / "input" / "paper.pdf"
|
| 50 |
dst_pdf = P2P_ROOT / "input" / "paper" / "paper.pdf"
|
| 51 |
dst_pdf.parent.mkdir(parents=True, exist_ok=True)
|
| 52 |
safe_copy(src_pdf, dst_pdf)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
cmd = [
|
| 54 |
sys.executable, "-m", "PosterAgent.new_pipeline",
|
| 55 |
f'--poster_path={dst_pdf.relative_to(P2P_ROOT)}',
|
| 56 |
'--model_name_t=gpt-5',
|
| 57 |
'--model_name_v=gpt-5',
|
| 58 |
-
'--poster_width_inches=
|
| 59 |
-
'--poster_height_inches=
|
| 60 |
]
|
| 61 |
print(" ▶ Running: python -m PosterAgent.new_pipeline ...")
|
| 62 |
subprocess.run(cmd, cwd=str(P2P_ROOT), check=True)
|
|
@@ -193,6 +199,7 @@ if __name__ == '__main__':
|
|
| 193 |
parser.add_argument('--openai_key', type=str, required=True, help='Your OpenAI API key')
|
| 194 |
parser.add_argument('--gemini_key', type=str, required=True, help='Your Gemini API key')
|
| 195 |
parser.add_argument('--logo_dir', type=str, required=True, help='Directory containing uploaded logo image(s)')
|
|
|
|
| 196 |
args = parser.parse_args()
|
| 197 |
print("start")
|
| 198 |
|
|
@@ -301,7 +308,7 @@ if __name__ == '__main__':
|
|
| 301 |
# Step 1.5: Poster2Poster 内容生成
|
| 302 |
# =========================
|
| 303 |
try:
|
| 304 |
-
run_paper2poster_content_build()
|
| 305 |
except Exception as e:
|
| 306 |
print(f"❌ Step 1.5 failed: {e}")
|
| 307 |
|
|
@@ -310,7 +317,7 @@ if __name__ == '__main__':
|
|
| 310 |
# =========================
|
| 311 |
try:
|
| 312 |
print("🧩 Step 2: Building poster ...")
|
| 313 |
-
build_poster()
|
| 314 |
print("✅ Step 2 done.")
|
| 315 |
except Exception as e:
|
| 316 |
print(f"❌ Step 2 failed: {e}")
|
|
|
|
| 43 |
def str2list(s):
|
| 44 |
return [int(x) for x in s.split(',')]
|
| 45 |
|
| 46 |
+
def run_paper2poster_content_build(orientation="landscape"):
|
| 47 |
print("🧩 Step 1.5: Preparing Paper2Poster inputs & generating poster contents ...")
|
| 48 |
|
| 49 |
src_pdf = ROOT_DIR / "input" / "paper.pdf"
|
| 50 |
dst_pdf = P2P_ROOT / "input" / "paper" / "paper.pdf"
|
| 51 |
dst_pdf.parent.mkdir(parents=True, exist_ok=True)
|
| 52 |
safe_copy(src_pdf, dst_pdf)
|
| 53 |
+
|
| 54 |
+
if orientation.lower() == "portrait":
|
| 55 |
+
width_in, height_in = "36", "48"
|
| 56 |
+
else:
|
| 57 |
+
width_in, height_in = "48", "36"
|
| 58 |
+
|
| 59 |
cmd = [
|
| 60 |
sys.executable, "-m", "PosterAgent.new_pipeline",
|
| 61 |
f'--poster_path={dst_pdf.relative_to(P2P_ROOT)}',
|
| 62 |
'--model_name_t=gpt-5',
|
| 63 |
'--model_name_v=gpt-5',
|
| 64 |
+
f'--poster_width_inches={width_in}',
|
| 65 |
+
f'--poster_height_inches={height_in}'
|
| 66 |
]
|
| 67 |
print(" ▶ Running: python -m PosterAgent.new_pipeline ...")
|
| 68 |
subprocess.run(cmd, cwd=str(P2P_ROOT), check=True)
|
|
|
|
| 199 |
parser.add_argument('--openai_key', type=str, required=True, help='Your OpenAI API key')
|
| 200 |
parser.add_argument('--gemini_key', type=str, required=True, help='Your Gemini API key')
|
| 201 |
parser.add_argument('--logo_dir', type=str, required=True, help='Directory containing uploaded logo image(s)')
|
| 202 |
+
parser.add_argument('--orientation', type=str, choices=['landscape', 'portrait'], default='landscape', help='Poster layout orientation')
|
| 203 |
args = parser.parse_args()
|
| 204 |
print("start")
|
| 205 |
|
|
|
|
| 308 |
# Step 1.5: Poster2Poster 内容生成
|
| 309 |
# =========================
|
| 310 |
try:
|
| 311 |
+
run_paper2poster_content_build(orientation=args.orientation)
|
| 312 |
except Exception as e:
|
| 313 |
print(f"❌ Step 1.5 failed: {e}")
|
| 314 |
|
|
|
|
| 317 |
# =========================
|
| 318 |
try:
|
| 319 |
print("🧩 Step 2: Building poster ...")
|
| 320 |
+
build_poster(orientation=args.orientation)
|
| 321 |
print("✅ Step 2 done.")
|
| 322 |
except Exception as e:
|
| 323 |
print(f"❌ Step 2 failed: {e}")
|