Download mind3d_trellis2/code/mapper/valsel_select.py from jamie33/926: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/jamie33/926/resolve/main/mind3d_trellis2/code/mapper/valsel_select.py
- Command line
-
hf download hf://datasets/jamie33/926/mind3d_trellis2/code/mapper/valsel_select.py
-
curl -L -o valsel_select.py https://huggingface.co/datasets/jamie33/926/resolve/main/mind3d_trellis2/code/mapper/valsel_select.py
1.53 kB
| """Pick (output variant, CFG) per family by mean val CD; the test set is then generated/evaluated once with the pick.""" | |
| import glob | |
| import json | |
| import os | |
| import numpy as np | |
| O = "/home/hubin/trellis_work/outputs/valsel" | |
| FAMILIES = {"no_labels": ["ridge_k64_rescaled"], | |
| "labels": ["clsfirst_knn1_resid_k64_rescaled", "v2ens5_coef_rescaled", "v2ens5_clsmean_resid", | |
| "v2ens5_clsmean"]} | |
| def main(): | |
| table = {} | |
| for d in sorted(glob.glob(f"{O}/val/*_cfg*/metrics.json")): | |
| name = os.path.basename(os.path.dirname(d)) | |
| rows = json.load(open(d))["rows"] | |
| cd = np.array([r["cd"] for r in rows]) * 1e3 | |
| table[name] = {"n": len(rows), "cd_x1e3": float(cd.mean()), "median": float(np.median(cd)), | |
| "fscore@0.02": float(np.mean([r["fscore"] for r in rows]))} | |
| sel = {} | |
| for fam, variants in FAMILIES.items(): | |
| cands = {n: m for n, m in table.items() if n.rsplit("_cfg", 1)[0] in variants} | |
| best = min(cands, key=lambda n: cands[n]["cd_x1e3"]) | |
| v, c = best.rsplit("_cfg", 1) | |
| sel[fam] = {"variant": v, "cfg": c, "val_cd_x1e3": cands[best]["cd_x1e3"]} | |
| for n, m in sorted(table.items(), key=lambda kv: kv[1]["cd_x1e3"]): | |
| print(f"{n:45s} n={m['n']:3d} CD {m['cd_x1e3']:6.2f} median {m['median']:6.2f} F {m['fscore@0.02']:.3f}") | |
| print(json.dumps(sel, indent=1)) | |
| json.dump({"selection": sel, "val_table": table}, open(f"{O}/selection.json", "w"), indent=1) | |
| if __name__ == "__main__": | |
| main() | |