"""Publication panel for the real-world (truck) scene: clean | faulted | guarded | |error|. We search several orbit views and many candidate sites for the most visible scale sign-bit upset, then show the absolute-error map so the corruption footprint is legible regardless of the (off-distribution) viewpoint sharpness.""" import os, numpy as np, torch import matplotlib; matplotlib.use("Agg") import matplotlib.pyplot as plt plt.rcParams.update({"font.family": "serif", "mathtext.fontset": "cm", "font.size": 11, "savefig.dpi": 220, "savefig.bbox": "tight"}) import faultlib as F from realscene import load_ply, orbit_cameras PLY = "/root/seu/data/truck.ply"; GEN = "/root/seu/results/generated" dev = "cuda" params, sh, N = load_ply(PLY) W = H = 900 vms, Ks = orbit_cameras(params["means"], 8, W, H) bounds = F.compute_bounds(params) stored, work = F.quantize_params(params, "fp32") clean, _ = F.render_views(work, vms, Ks, W, H, sh) rng = np.random.default_rng(7) best = (-1.0, 0, 0) # footprint, view, gaussian sc = work["scales"] for _ in range(450): v = int(rng.integers(0, 8)); g = int(rng.integers(0, N)); flat = g * 3 cv, _ = F.flip_one(stored["scales"], sc, flat, 31, "fp32") img, _ = F.render_views(work, vms[v:v+1], Ks[v:v+1], W, H, sh) F.restore_one(sc, flat, cv) fp = ((img[0] - clean[v]).abs().amax(-1) > 1/255).float().mean().item() if fp > best[0]: best = (fp, v, g) fp, v, g = best; flat = g * 3 print(f"chosen view={v} gaussian={g} footprint={fp*100:.1f}%", flush=True) cv, _ = F.flip_one(stored["scales"], sc, flat, 31, "fp32") faulted, _ = F.render_views(work, vms[v:v+1], Ks[v:v+1], W, H, sh) gw = F.apply_guard(work, bounds) guarded, _ = F.render_views(gw, vms[v:v+1], Ks[v:v+1], W, H, sh) F.restore_one(sc, flat, cv) cl = clean[v].clamp(0,1).cpu().numpy(); fa = faulted[0].clamp(0,1).cpu().numpy(); gu = guarded[0].clamp(0,1).cpu().numpy() err = np.abs(fa - cl).max(-1) fig, ax = plt.subplots(1, 4, figsize=(13, 3.5)) for a in ax: a.set_xticks([]); a.set_yticks([]) ax[0].imshow(cl); ax[0].set_title("clean") ax[1].imshow(fa); ax[1].set_title(f"faulted (footprint {fp*100:.0f}\\%)") ax[2].imshow(gu); ax[2].set_title("support guard") vmx=float(np.percentile(err,99.5)); im = ax[3].imshow(err, cmap="inferno", vmin=0, vmax=max(vmx,0.02)); ax[3].set_title("$|\\Delta I|_\\infty$ (faulted)") cb = fig.colorbar(im, ax=ax[3], fraction=0.046, pad=0.04); cb.set_label("abs. error") plt.tight_layout() plt.savefig(os.path.join(GEN, "fig_realscene.pdf"), bbox_inches="tight") print("WROTE fig_realscene.pdf", flush=True)