#!/usr/bin/env python """Final comparison: chosen checkpoint (steps2000) on the full 160-edit held-out set at 40 steps, run twice: with the transparency suffix (deployed usage, matches training captions) and without (apples-to-apples with the baselines, which ran bare instructions). Reuses eval_edit.py's pipeline, metrics and seeding so numbers are directly comparable to the baseline run. Usage: python final_eval.py --lora /ckpts/orbit_alpha_lora.safetensors --out /out/final """ import argparse, json, os, sys import eval_edit as E def main(): ap = argparse.ArgumentParser() ap.add_argument('--lora', required=True) ap.add_argument('--out', required=True) args = ap.parse_args() pairs = [json.loads(l) for l in open(E.get_file('pairs_eval.jsonl'))] assert len(pairs) == 160, f'expected 160 eval pairs, got {len(pairs)}' pipe = E.load_pipe() m = E.make_metrics() pipe.load_lora_weights(args.lora) for variant, suffix in (('no_suffix', ''), ('suffix', ' ' + E.ALPHA_SUFFIX)): pv = [dict(p, instruction=p['instruction'] + suffix) for p in pairs] r = E.run_pairs(pipe, m, pv, 'instruction', os.path.join(args.out, variant)) E.agg(r, f'FINAL/{variant}') # side-by-side contact sheet: pred-with-suffix vs GT for 12 objects try: from PIL import Image sheet_pairs = pairs[::13][:12] tiles = [] for p in sheet_pairs: pred = Image.open(os.path.join(args.out, 'suffix', p['pair_id'] + '.png')) gt = Image.open(E.get_file(p['target_file'])).convert('RGBA') for im in (pred, gt): bg = Image.new('RGB', im.size, (128, 128, 128)) bg.paste(im, mask=im.split()[3]) tiles.append(bg.resize((256, 256))) sheet = Image.new('RGB', (256 * 4, 256 * 6), (30, 30, 30)) for i, t in enumerate(tiles): sheet.paste(t, ((i % 4) * 256, (i // 4) * 256)) sheet.save(os.path.join(args.out, 'final_sheet.png')) print('sheet written', flush=True) except Exception as e: print(f'sheet failed (non-fatal): {e}', flush=True) print('DONE', flush=True) if __name__ == '__main__': main()