current_works_v2: layout-only guidance weight sweep (20 configs, 370 test scenes) (part 2)
e29a5d7 verified Download current_works_v2/sweep_layout_only/table.py from rabbitKabbit/GuidedScene: direct link, hf CLI and curl.
- Browser
- Download file 2.35 kB
-
https://huggingface.co/datasets/rabbitKabbit/GuidedScene/resolve/main/current_works_v2/sweep_layout_only/table.py
- Command line
-
hf download hf://datasets/rabbitKabbit/GuidedScene/current_works_v2/sweep_layout_only/table.py
-
curl -L -o table.py https://huggingface.co/datasets/rabbitKabbit/GuidedScene/resolve/main/current_works_v2/sweep_layout_only/table.py
2.35 kB
| """Sweep table: metrics raw and after PP, object size and PP displacement vs the layout-only baseline.""" | |
| import re, json, os, numpy as np | |
| H = os.path.dirname(os.path.abspath(__file__)) | |
| def g(p, pat): | |
| try: m = re.search(pat, open(p).read()); return float(m.group(1)) if m else float('nan') | |
| except FileNotFoundError: return float('nan') | |
| def load(p): | |
| d = json.load(open(p)); V, C = [], [] | |
| for i in range(len(d['sizes'])): | |
| s = np.array(d['sizes'][i]).reshape(-1, 3); c = np.array(d['class_labels'][i]).reshape(len(s), -1).argmax(-1) | |
| V += list(np.prod(s, 1)); C += list(c) | |
| return np.array(V), np.array(C) | |
| names = sorted(f[:-5] for f in os.listdir(f'{H}/raw') if f.endswith('.json') and not f.startswith('relational')) | |
| names = (['baseline'] if 'baseline' in names else []) + [n for n in names if n != 'baseline'] | |
| Vb, Cb = load(f'{H}/raw/baseline.json') if 'baseline' in names else (None, None) | |
| dmg = json.load(open(f'{H}/pp_damage_summary.json')) if os.path.exists(f'{H}/pp_damage_summary.json') else {} | |
| print('| Config | Size | ColObj raw | ColObj PP | ColScene PP | OOB raw | OOB PP | SG raw | SG PP | Close PP | Symm PP | PP move cm | PP flips % |') | |
| print('|' + '---|' * 13) | |
| for n in names: | |
| e = lambda st, k: f'{H}/eval/{n}_{st}_{k}.txt' | |
| size = float('nan') | |
| if Vb is not None: | |
| V, C = load(f'{H}/raw/{n}.json') | |
| size = np.mean([np.median(V[C == k]) / np.median(Vb[Cb == k]) for k in np.unique(Cb) if (C == k).sum() > 20 and (Cb == k).sum() > 20]) | |
| d = dmg.get(n, {}) | |
| row = [size * 100, g(e('raw', 'col'), r'Overall ColObj.*?: ([\d.]+)'), g(e('pp', 'col'), r'Overall ColObj.*?: ([\d.]+)'), | |
| g(e('pp', 'col'), r'Overall ColScene.*?: ([\d.]+)'), g(e('raw', 'ob'), r'Average #OB per scene: ([\d.]+)'), | |
| g(e('pp', 'ob'), r'Average #OB per scene: ([\d.]+)'), g(e('raw', 'rel'), r'Total Acc\)\s*: ([\d.]+)'), | |
| g(e('pp', 'rel'), r'Total Acc\)\s*: ([\d.]+)'), g(e('pp', 'rel'), r'Close By\s*: ([\d.]+)'), | |
| g(e('pp', 'rel'), r'Symmetrical To\s*: ([\d.]+)'), | |
| d.get('mean_cm', float('nan')), d.get('scene_flip_pct', float('nan'))] | |
| fmt = ['{:.0f}%', '{:.4f}', '{:.4f}', '{:.4f}', '{:.3f}', '{:.3f}', '{:.2f}', '{:.2f}', '{:.2f}', '{:.2f}', '{:.1f}', '{:.1f}'] | |
| print(f'| {n} | ' + ' | '.join(f.format(x) for f, x in zip(fmt, row)) + ' |') | |