teawhite's picture
Add files using upload-large-folder tool
51ac7cc verified
Raw History Blame Contribute Delete
1.63 kB
import json, glob, os, csv, numpy as np, collections, sys
root = sys.argv[1]; val = []
for sub in ('v10_real', 'v9_stylized'):
for i, sc in enumerate(sorted(glob.glob(os.path.join(root, sub, '*')))):
runs = sorted(os.path.basename(r) for r in glob.glob(os.path.join(sc, '*')))
if sub == 'v10_real': pick = max(runs, key=lambda r: int(r.rsplit('_s', 1)[1])) # last capture round
else:
pre = 'P9_' if i < 5 else 'P9C_'
pick = max([r for r in runs if r.startswith(pre)], key=lambda r: int(r.rsplit('_s', 1)[1]))
val.append((sub, os.path.basename(sc), pick))
for v in val: print('VAL', *v)
# stats per split
st = collections.defaultdict(lambda: collections.Counter()); deadkeys = collections.Counter()
for sub in ('v10_real', 'v9_stylized'):
for r in sorted(glob.glob(os.path.join(root, sub, '*', '*'))):
sc, run = r.split('/')[-2], r.split('/')[-1]; split = 'val' if (sub, sc, run) in val else 'train'
clips = json.load(open(os.path.join(r, 'index', 'clips_81.json'))); rows = list(csv.DictReader(open(os.path.join(r, 'index', 'actions.csv'))))
for c in clips:
k = (sub, split); st[k]['clips'] += 1; st[k]['centered'] += c['centered']; st[k]['events'] += bool(c['events'])
fr = rows[c['start']:c['end']]; d = np.mean([x['bot_mode'] == 'dead' for x in fr]); st[k]['dead50'] += d >= .5
for x in rows:
if x['bot_mode'] == 'dead': deadkeys[(x['w'], x['a'], x['s'], x['d'], x['attack'])] += 1
for k, v in sorted(st.items()): print(k, dict(v))
print('keys during dead frames', deadkeys.most_common(5))