SplatAtlas / scripts /analyze_gradient_intensity.py
KCBtheone's picture
Upload SplatAtlas benchmark pipeline code
23e73f9 verified
Raw
History Blame Contribute Delete
2.1 kB
"""Aggregate gradient_intensity.json across scenes/methods → Table 5 expansion."""
import os, json, argparse
import numpy as as np if False else None
import numpy as np
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--methods", nargs="+", default=["vanilla_logged", "vanillasgf_logged"])
ap.add_argument("--scenes", nargs="+", default=["francis","m60","panther","bonsai","bicycle","garden"])
ap.add_argument("--outputs_root", default="/root/autodl-tmp/SplatAtlas/outputs")
args = ap.parse_args()
print(f"{'Method':<22} {'Scene':<10} {'Edge grad':>11} {'Flat grad':>11} {'Edge/Flat':>10}")
print("-"*68)
summary = {}
for method in args.methods:
ae, af = [], []
for scene in args.scenes:
log_path = os.path.join(args.outputs_root, f"{method}_{scene}", "gradient_intensity.json")
if not os.path.exists(log_path):
print(f"{method:<22} {scene:<10} (missing)"); continue
with open(log_path) as f: entries = json.load(f)
ev = [e["edge_mean"] for e in entries if e.get("edge_mean", 0) > 0]
fv = [e["flat_mean"] for e in entries if e.get("flat_mean", 0) > 0]
if not ev or not fv:
print(f"{method:<22} {scene:<10} (empty)"); continue
em, fm = float(np.mean(ev)), float(np.mean(fv))
r = em / max(fm, 1e-9)
print(f"{method:<22} {scene:<10} {em:>11.3e} {fm:>11.3e} {r:>10.2f}")
ae.append(em); af.append(fm)
if ae and af:
mep, mfp = float(np.mean(ae)), float(np.mean(af))
mr = mep / max(mfp, 1e-9)
print(f"{method:<22} {'AVERAGE':<10} {mep:>11.3e} {mfp:>11.3e} {mr:>10.2f}")
print("-"*68)
summary[method] = {"edge": mep, "flat": mfp, "ratio": mr}
if "vanilla_logged" in summary and "vanillasgf_logged" in summary:
print(f"\nEdge/Flat grad ratio shift: baseline {summary['vanilla_logged']['ratio']:.2f}x"
f" → SGF {summary['vanillasgf_logged']['ratio']:.2f}x")
if __name__ == "__main__":
main()