| |
| """Turn each monument image into a 3D gaussian splat (.ply) via the |
| VAST-AI/TripoSplat Gradio space.""" |
| import pathlib, sys, time |
| import hf_call |
|
|
| ROOT = "https://vast-ai-triposplat.hf.space" |
| IMG = pathlib.Path(__file__).parent / "images" |
| OUT = pathlib.Path(__file__).parent / "splats" |
| OUT.mkdir(exist_ok=True) |
|
|
| SLUGS = ["tour-eiffel", "louvre-pyramid", "arc-de-triomphe", |
| "sacre-coeur", "notre-dame", "obelisque"] |
|
|
| |
| if len(sys.argv) > 1: |
| SLUGS = sys.argv[1:] |
|
|
| for slug in SLUGS: |
| src = IMG / f"{slug}.jpg" |
| dest = OUT / f"{slug}.ply" |
| if dest.exists(): |
| print(f"[skip] {slug}", flush=True) |
| continue |
| if not src.exists(): |
| print(f"[miss] {slug} image not found", flush=True) |
| continue |
| ok = False |
| for attempt in range(1, 5): |
| try: |
| print(f"[up ] {slug} uploading image (try {attempt}) ...", flush=True) |
| filedata = hf_call.upload(ROOT, src) |
| print(f"[gen ] {slug} generating splat (this can take a few min) ...", flush=True) |
| data = hf_call.call(ROOT, "generate", [ |
| filedata, |
| 42, |
| 20, |
| 3.0, |
| 262144, |
| "ply", |
| ], timeout=1800) |
| |
| ply = data[1] |
| hf_call.download(ply, dest, space_root=ROOT) |
| print(f"[ok ] {slug} -> {dest} ({dest.stat().st_size//1024} kB)", flush=True) |
| ok = True |
| break |
| except Exception as e: |
| print(f"[err ] {slug} attempt {attempt}: {e}", flush=True) |
| time.sleep(15) |
| if not ok: |
| print(f"[FAIL] {slug} gave up after retries", flush=True) |
|
|
| print("DONE") |
|
|