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 def scene_ids(args) -> list[str]: scenes = [s for split in args.split or [] for _, s in build_scenes.split_segments(args.data_root, split)] if args.scene: scenes = list(args.scene) if not scenes: raise SystemExit('give --split and/or --scene') return sorted(dict.fromkeys(scenes)) def main() -> int: parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('label', choices=('depth', 'sky', 'visibility')) parser.add_argument('--data-root', type=Path, required=True, help='AmodalDrive dataset root with the rebuilt scenes/') parser.add_argument('--waymo-root', type=Path, help='Waymo v2.0.1 parquet root (depth, sky)') parser.add_argument('--split', action='append', choices=('val', 'test')) parser.add_argument('--scene', action='append', help='only these scenes (repeatable)') parser.add_argument('--workers', type=int, default=4, help='depth: worker processes') parser.add_argument('--segformer', default='nvidia/segformer-b5-finetuned-cityscapes-1024-1024', help='sky: hub id or local snapshot directory') parser.add_argument('--dggt-checkpoint', type=Path, help='visibility: DGGT Waymo checkpoint (model_latest_waymo.pt)') args = parser.parse_args() if args.label in ('depth', 'sky') and args.waymo_root is None: parser.error('--waymo-root is required') if args.label == 'depth': from agt.dataset import lidar_depth failed = lidar_depth.generate(args.data_root, args.waymo_root, scene_ids(args), workers=args.workers) elif args.label == 'sky': from agt.dataset import sky failed = sky.generate(args.data_root, args.waymo_root, scene_ids(args), segformer=args.segformer) else: if args.dggt_checkpoint is None: parser.error('--dggt-checkpoint is required') from agt.data.scene import SceneIndex from agt.dataset import visibility wanted = set(scene_ids(args)) records = [r for split in (args.split or ['val', 'test']) for r in SceneIndex.from_data_root(args.data_root, split, sources=['waymo']).records if r.scene_id in wanted] failed = visibility.generate(args.data_root, sorted(records, key=lambda r: r.scene_id), args.dggt_checkpoint) print(f'failed scenes: {failed}', flush=True) return 1 if failed else 0 if __name__ == '__main__': sys.exit(main())