Download mind3d_trellis2/code/mapper/supp_table.py from jamie33/926: direct link, hf CLI and curl.
- Browser
- Download file 4.63 kB
-
https://huggingface.co/datasets/jamie33/926/resolve/main/mind3d_trellis2/code/mapper/supp_table.py
- Command line
-
hf download hf://datasets/jamie33/926/mind3d_trellis2/code/mapper/supp_table.py
-
curl -L -o supp_table.py https://huggingface.co/datasets/jamie33/926/resolve/main/mind3d_trellis2/code/mapper/supp_table.py
4.63 kB
| """Summary of the supplementary experiments -> outputs/supp/supp_results.json.""" | |
| import json | |
| import os | |
| import numpy as np | |
| O = "/home/hubin/trellis_work/outputs" | |
| S = f"{O}/supp" | |
| M = "/home/hubin/hf_upload/926_meshes/mind3d_trellis2/meshes" | |
| METRICS = "/home/hubin/hf_upload/mind3d-trellis2/results/metrics" | |
| OURS = f"{O}/ft/frozen_0001/sub0001/test_coef_rescaled_cfg50/metrics.json" | |
| MIND3D = f"{O}/mind3d_sub01/metrics.json" | |
| def cds(path): | |
| return {r["id"]: r["cd"] * 1e3 for r in json.load(open(path))["rows"]} if os.path.exists(path) else None | |
| def paired(a, b, ids, n=10000): | |
| d = np.array([a[k] - b[k] for k in ids]) | |
| bs = np.random.default_rng(0).choice(d, (n, len(d))).mean(1) | |
| return {"mean_diff": float(d.mean()), "ci95": [float(np.percentile(bs, 2.5)), float(np.percentile(bs, 97.5))], | |
| "n_better": int((d < 0).sum()), "n": len(d)} | |
| def mean(a, ids): | |
| return float(np.mean([a[k] for k in ids])) | |
| res = {} | |
| ours, mind3d = cds(OURS), cds(MIND3D) | |
| # val CFG sweep for the final model (20 / 50 from round 10) | |
| sweep = {20: f"{O}/sslora/val/base_cfg20/metrics.json", 50: f"{O}/sslora/val/base_cfg50/metrics.json"} | |
| sweep.update({c: f"{S}/val_cfg{c}/metrics.json" for c in (30, 75, 100)}) | |
| res["val_cfg_sweep"] = {str(c): json.load(open(p))["summary"]["cd_x1e3"] for c, p in sorted(sweep.items()) | |
| if os.path.exists(p)} | |
| # 4 generation seeds on test | |
| seeds = [cds(f"{S}/test_seeds/metrics{j}.json") for j in ("", "_s1", "_s2", "_s3")] | |
| if all(seeds): | |
| ids = sorted(set.intersection(*[set(s) for s in seeds])) | |
| per = [mean(s, ids) for s in seeds] | |
| e = {k: np.mean([s[k] for s in seeds]) for k in ids} | |
| res["test_seeds"] = {"per_seed": per, "mean": float(np.mean(per)), "std_over_seeds": float(np.std(per, ddof=1)), | |
| "expected_cd_vs_mind3d": paired(e, mind3d, ids), | |
| "per_seed_vs_mind3d": [paired(s, mind3d, ids)["mean_diff"] for s in seeds]} | |
| # category holdout | |
| folds = json.load(open(f"{S}/cat_folds.json")) | |
| h = {n: cds(f"{S}/{n}/metrics.json") for n in ("holdout_ours", "holdout_gt16", "holdout_zero")} | |
| if h["holdout_ours"]: | |
| ids = sorted(set(h["holdout_ours"]) & set(ours) & set(mind3d)) | |
| gt16_in = cds(f"{O}/diag/pca16/metrics.json") | |
| rows = {"ours_heldout": h["holdout_ours"], "ours_in_distribution": ours, "mind3d": mind3d} | |
| if h["holdout_gt16"]: | |
| rows["gt_pca16_heldout_basis"] = h["holdout_gt16"] | |
| if gt16_in: | |
| rows["gt_pca16_in_distribution"] = gt16_in | |
| if h["holdout_zero"]: | |
| rows["zero_coef_heldout_basis"] = h["holdout_zero"] | |
| ok = [k for k in ids if all(k in r for r in rows.values())] | |
| out = {"n": len(ok), "mean": {n: mean(r, ok) for n, r in rows.items()}, | |
| "ours_heldout_vs_mind3d": paired(h["holdout_ours"], mind3d, ok), | |
| "ours_heldout_vs_in_distribution": paired(h["holdout_ours"], ours, ok), "per_fold": {}} | |
| if h["holdout_zero"]: | |
| out["ours_heldout_vs_zero_coef"] = paired(h["holdout_ours"], h["holdout_zero"], ok) | |
| for f, cs in enumerate(folds): | |
| fi = [k for k in ok if k.split("/")[0] in cs] | |
| out["per_fold"][str(f)] = {"categories": cs, "n": len(fi), **{n: mean(r, fi) for n, r in rows.items()}} | |
| ident = f"{S}/ident/summary.json" | |
| if os.path.exists(ident): | |
| out["identification"] = json.load(open(ident)) | |
| res["category_holdout"] = out | |
| # evaluation robustness: 24 azimuths x 2 up-axes + rigid ICP | |
| rob = {} | |
| for f in sorted(os.listdir(f"{S}/robust")) if os.path.isdir(f"{S}/robust") else []: | |
| if f.endswith(".json"): | |
| name = f[:-5] | |
| rob[name] = {"robust": json.load(open(f"{S}/robust/{f}"))["summary"]["cd_x1e3"], | |
| "default": json.load(open(f"{METRICS}/{name}.json"))["summary"]["cd_x1e3"]} | |
| if "ft_frozen_sub01_k16_cfg50" in rob and "mind3d_official" in rob: | |
| a, b = cds(f"{S}/robust/ft_frozen_sub01_k16_cfg50.json"), cds(f"{S}/robust/mind3d_official.json") | |
| rob["ours_vs_mind3d_robust"] = paired(a, b, sorted(set(a) & set(b))) | |
| res["eval_robustness"] = rob | |
| # MinD-3D on its own training objects (our val split) vs test | |
| tr = cds(f"{S}/mind3d_trainobj/metrics.json") | |
| if tr: | |
| v_ours = cds(f"{O}/sslora/val/base_cfg50/metrics.json") | |
| ids = sorted(set(tr) & set(v_ours)) | |
| res["mind3d_train_vs_test"] = {"n_train_objects": len(ids), "mind3d_on_training_objects": mean(tr, ids), | |
| "mind3d_on_test": mean(mind3d, sorted(mind3d)), | |
| "ours_on_same_objects_heldout": mean(v_ours, ids)} | |
| json.dump(res, open(f"{S}/supp_results.json", "w"), indent=1) | |
| print(json.dumps(res, indent=1)) | |