""" Qualitative comparison: blurry input vs deblurred outputs. No GT reference. Just visual quality comparison. Columns: Blur input | EVSSM | VD-Diff | TURTLE (if available) """ import numpy as np from pathlib import Path from PIL import Image, ImageDraw BASE = Path(__file__).parent.parent METHODS = [ ("blur", "Blur Input", BASE / "data/scannet_blur_proto/vddiff/test/blur"), ("evssm", "EVSSM", BASE / "data/evssm_deblurred"), ("vdiff", "VD-Diff", BASE / "data/vdiff_deblurred"), ("turtle", "TURTLE", BASE / "data/turtle_deblurred"), ] def label_bar(text, w, h=36, bg=(30,30,30), fg=(255,255,255)): img = Image.new("RGB", (w, h), bg) draw = ImageDraw.Draw(img) bbox = draw.textbbox((0,0), text) tw, th = bbox[2]-bbox[0], bbox[3]-bbox[1] draw.text(((w-tw)//2, (h-th)//2), text, fill=fg) return np.array(img) def load(path, scale=None): img = Image.open(path).convert("RGB") if scale and scale < 1.0: w, h = img.size img = img.resize((int(w*scale), int(h*scale)), Image.LANCZOS) return np.array(img) def make_row(scene, frame_idx, scale=0.45, crop=None): fname = f"{frame_idx:06d}.png" cols = [] for key, label, root in METHODS: path = root / scene / fname if not path.exists(): continue img = load(path, scale=scale if crop is None else None) if crop: y1,x1,y2,x2 = crop img = np.array(Image.open(path).convert("RGB"))[y1:y2, x1:x2] bar = label_bar(label, img.shape[1]) cols.append(np.vstack([bar, img])) if not cols: return None max_h = max(c.shape[0] for c in cols) return np.hstack([np.vstack([c, np.zeros((max_h-c.shape[0], c.shape[1], 3), np.uint8)]) for c in cols]) def save_grid(rows, title, out_path): title_bar = label_bar(title, rows[0].shape[1], h=30, bg=(60,30,30)) grid = np.vstack([title_bar] + rows) Image.fromarray(grid).save(out_path, quality=93) print(f" → {out_path}") out_dir = BASE / "outputs/eval/qualitative_ngt" out_dir.mkdir(parents=True, exist_ok=True) scenes = ["scene0000_00", "scene0000_01", "scene0000_02"] frame_idxs = [0, 15, 30, 45] crops = { "full": None, "center": (280, 380, 620, 900), # y1,x1,y2,x2 — around centre "top": (0, 300, 280, 900), # top region } for scene in scenes: print(f"\n[{scene}]") for crop_name, crop in crops.items(): rows = [r for fi in frame_idxs if (r := make_row(scene, fi, scale=0.42, crop=crop)) is not None] if rows: save_grid(rows, f"{scene} [{crop_name}]", out_dir / f"{scene}_{crop_name}.jpg")