File size: 910 Bytes
cb179a8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """python example.py joint_plain.final.pt calibration_joint_plain.json chart.osu"""
import json
import sys
import numpy as np
import joint_infer
from osu_to_arrays import osu_to_arrays
ck, cal, osu = sys.argv[1:4]
model = joint_infer.load(ck)
arrays = osu_to_arrays(osu)
if arrays is None:
raise SystemExit("not a 4K mania chart with at least 64 rows")
out = model.predict(*arrays)
cal = json.load(open(cal))
stars = cal["linear"]["intercept"] + cal["linear"]["slope"] * out["difficulty"]
print(f"difficulty score {out['difficulty']:.2f} (about {stars:.2f} stars; isotonic: {np.interp(out['difficulty'], cal['isotonic']['x'], cal['isotonic']['y']):.2f})")
for t, p in sorted(zip(out["tasks"], out["tag_prob"]), key=lambda x: -x[1])[:8]:
print(f" {t:32s} {p:.2f}")
print("rows:", len(out["row_score"]), " hardest windows (512 rows each):", np.round(np.sort(out["window_difficulty"])[::-1][:3], 2))
|