File size: 1,710 Bytes
f877698
 
 
 
 
 
 
 
fb3460f
f877698
 
 
fb3460f
f877698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import argparse
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1]))

from agt.dataset import build_scenes, waymo


def main() -> int:
    parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument("--data-root", type=Path, required=True, help="AmodalDrive dataset root (scenes/ is written here)")
    parser.add_argument("--waymo-root", type=Path, required=True, help="Waymo v2.0.1 parquet root (read-only)")
    parser.add_argument("--split", action="append", choices=("val", "test"), help="evaluation split(s) to build")
    parser.add_argument("--segment", action="append", help="only these segments (repeatable)")
    parser.add_argument("--workers", type=int, default=3)
    parser.add_argument("--ffmpeg", default="ffmpeg", help="ffmpeg with libx265 (the reference build is ffmpeg 7.0.2 static, x265 3.5)")
    parser.add_argument("--ffprobe", default="ffprobe")
    args = parser.parse_args()
    segments = []
    for split in args.split or []:
        segments += build_scenes.split_segments(args.data_root, split)
    if args.segment:
        known = dict((s, sp) for sp, s in segments)
        segments = [(known.get(s) or waymo.find_split(args.waymo_root, s), s) for s in args.segment]
    if not segments:
        parser.error("give --split and/or --segment")
    failed = build_scenes.build(args.data_root, args.waymo_root, segments, ffmpeg=args.ffmpeg, ffprobe=args.ffprobe,
                                workers=args.workers)
    print(f"failed segments: {failed}", flush=True)
    return 1 if failed else 0


if __name__ == "__main__":
    sys.exit(main())