Datasets:
File size: 2,078 Bytes
f053b90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #!/usr/bin/env python3
"""Re-score the stored per-item outputs of VeriSpoof-Base / -Plus (reference_results/<model>/<subset>.parquet) with
scripts/score.py and compare with the metrics reported by the research evaluation (reported_metrics.json).
python scripts/check_reference.py [--bench <dataset dir>]
Metrics that need model log-probabilities not stored per item (ad_reasoning eer_loc, flip_rate, head_* token-head
metrics, held-out faithfulness rates) are listed as not re-scorable.
"""
import argparse
import json
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import score as SC # noqa: E402
HERE = os.path.dirname(os.path.abspath(__file__))
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--bench", default=os.path.join(HERE, ".."))
a = ap.parse_args()
ok = True
for model in ("verispoof_base", "verispoof_plus"):
d = f"{a.bench}/reference_results/{model}"
rep = json.load(open(f"{d}/reported_metrics.json"))
n_cmp, worst, skipped = 0, (0.0, None), set()
for s, r in rep.items():
items = SC.load_items(a.bench, s)
m = SC.score_subset(items, SC.read_table(f"{d}/{s}"), None, s)
for k, v in r.items():
if not isinstance(v, (int, float)) or isinstance(v, bool):
continue
if k not in m or m[k] is None:
skipped.add(k)
continue
diff = abs(m[k] - v)
n_cmp += 1
if diff > worst[0]:
worst = (diff, f"{s}:{k} rescored {m[k]} reported {v}")
if diff > 1e-3:
ok = False
print(f"MISMATCH {model} {s} {k}: rescored {m[k]} reported {v}")
print(f"{model}: {len(rep)} subsets, {n_cmp} metric values compared, max |diff| {worst[0]:.2g} ({worst[1]}); "
f"not re-scorable from stored outputs: {sorted(skipped)}")
print("ALL MATCH" if ok else "SOME MISMATCHES")
if __name__ == "__main__":
main()
|