43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
"""Print B0/B1 activity results in percent, with one explicit AP protocol."""
|
|||
|
|
|
||
|
|
import argparse
|
||
|
|
import json
|
||
|
|
from pathlib import Path
|
||
|
|
import re
|
||
|
|
import statistics
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
||
|
|
parser.add_argument("--root", type=Path, default=Path("results/easycom_local_b1"))
|
||
|
|
parser.add_argument("--protocol", choices=("causal_valid_only", "egospeak_full_timeline"), default="causal_valid_only")
|
||
|
|
args = parser.parse_args()
|
||
|
|
files = sorted(args.root.glob("*/metrics.json"))
|
||
|
|
if not files:
|
||
|
|
raise SystemExit(f"No */metrics.json in {args.root}")
|
||
|
|
print(f"Protocol: {args.protocol}; all AP/mAP numbers are percentages")
|
||
|
|
print(f"{'run':<23} {'0.2s mAP':>11} {'BG AP':>11} {'wearer AP':>11} {'others AP':>11} {'mean mAP':>11}")
|
||
|
|
groups = {}
|
||
|
|
for path in files:
|
||
|
|
metrics = json.loads(path.read_text())
|
||
|
|
score = metrics[args.protocol]
|
||
|
|
first = score["horizons"][0]
|
||
|
|
ap = first["class_ap"]
|
||
|
|
values = [100 * value for value in (first["map"], ap["background"],
|
||
|
|
ap["camera_wearer_speaking"], ap["other_people_speaking"], score["mean_map"])]
|
||
|
|
name = path.parent.name
|
||
|
|
print(f"{name:<23}" + "".join(f" {v:11.5f}" for v in values))
|
||
|
|
group = re.sub(r"_seed\d+$", "", name)
|
||
|
|
groups.setdefault(group, []).append(values)
|
||
|
|
print("\nMean ± sample standard deviation (AP/mAP percentage points)")
|
||
|
|
for group, rows in sorted(groups.items()):
|
||
|
|
stats = []
|
||
|
|
for column in zip(*rows):
|
||
|
|
spread = f"{statistics.stdev(column):.5f}" if len(column) > 1 else "n/a"
|
||
|
|
stats.append(f"{statistics.mean(column):.5f} ± {spread}")
|
||
|
|
print(f"{group:<23}" + " | ".join(stats))
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|