File size: 2,092 Bytes
ae419ed | 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 54 55 56 57 58 59 60 61 62 63 64 | from __future__ import annotations
import argparse
import subprocess
from pathlib import Path
from common import ROOT
def run(cmd: list[str]) -> None:
print(" ".join(cmd), flush=True)
subprocess.run(cmd, cwd=ROOT, check=True)
def main() -> None:
ap = argparse.ArgumentParser()
ap.add_argument("--datasets", nargs="+", default=["URFD", "MCFD"])
ap.add_argument("--methods", nargs="+", default=["lstm", "stgcn", "agcn", "ctrgcn", "posec3d", "tcnte", "dynafall"])
ap.add_argument("--seeds", nargs="+", type=int, default=[7, 13, 21])
ap.add_argument("--epochs", type=int, default=None)
ap.add_argument("--out-root", default="results/main")
args = ap.parse_args()
for seed in args.seeds:
for dataset in args.datasets:
processed = f"{dataset}_seed{seed}"
group_key = "scenario" if dataset == "MCFD" else "video"
run([
"python",
"scripts/prepare_clips.py",
"--dataset",
dataset,
"--seed",
str(seed),
"--group-key",
group_key,
"--output-name",
processed,
])
for method in args.methods:
out_dir = Path(args.out_root) / f"seed_{seed}" / dataset / method
if (ROOT / out_dir / "metrics_test_clean.json").exists():
print(f"skip existing {out_dir}", flush=True)
continue
cmd = [
"python",
"scripts/run_experiments.py",
"--dataset",
dataset,
"--processed-dataset",
processed,
"--methods",
method,
"--out-root",
str(Path(args.out_root) / f"seed_{seed}"),
]
if args.epochs is not None:
cmd.extend(["--epochs", str(args.epochs)])
run(cmd)
if __name__ == "__main__":
main()
|