"""Build Paraformer CSV lists (image_fn,label_fn) from the downloaded Chesapeake tiles. usage: python make_csv.py Writes per-split CSVs (train/val/test) for all states, plus per-state CSVs.""" import sys, glob, os, csv root, out = sys.argv[1], sys.argv[2] STATES = ["de", "ny", "md", "pa", "va", "wv"] SPLITS = ["train", "val", "test"] os.makedirs(out, exist_ok=True) rows = {s: [] for s in SPLITS} for st in STATES: for sp in SPLITS: naips = sorted(glob.glob(f"{root}/{st}/{st}_1m_*_extended-debuffered-{sp}_tiles/*_naip-new.tif")) pairs = [] for n in naips: l = n.replace("_naip-new.tif", "_nlcd.tif"); g = n.replace("_naip-new.tif", "_lc.tif") assert os.path.exists(l) and os.path.exists(g), n pairs.append((os.path.abspath(n), os.path.abspath(l), os.path.abspath(g))) rows[sp] += pairs with open(f"{out}/Chesapeake_{st}_{sp}.csv", "w", newline="") as f: w = csv.writer(f); w.writerow(["image_fn", "label_fn", "gt_fn"]); w.writerows(pairs) print(f"{st} {sp:5s} {len(pairs):4d}") for sp in SPLITS: with open(f"{out}/Chesapeake_all_{sp}.csv", "w", newline="") as f: w = csv.writer(f); w.writerow(["image_fn", "label_fn", "gt_fn"]); w.writerows(rows[sp]) print(f"ALL {sp:5s} {len(rows[sp]):4d} -> {out}/Chesapeake_all_{sp}.csv")