File size: 1,518 Bytes
b8ced22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Pack aligned RGB frames and upstream teacher outputs into a validated clip."""

import argparse
from pathlib import Path
import sys

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

import numpy as np
from pure.images import load_images
from pure.training.cache import ARRAY_KEYS, write_cache


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument(
        "--images",
        nargs="+",
        required=True,
        help="Frame paths in temporal order; no implicit resizing",
    )
    parser.add_argument(
        "--labels",
        required=True,
        help="NPZ containing the aligned depth/ray/mask/match arrays",
    )
    parser.add_argument("--output", required=True)
    parser.add_argument(
        "--teacher-prediction",
        help="Optional infer.py NPZ from the frozen base; provides teacher_xy",
    )
    args = parser.parse_args()
    images = load_images(args.images)
    with np.load(args.labels, allow_pickle=False) as archive:
        arrays = {
            key: archive[key].copy()
            for key in ARRAY_KEYS
            if key != "images" and not (key == "teacher_xy" and args.teacher_prediction)
        }
    if args.teacher_prediction:
        with np.load(args.teacher_prediction, allow_pickle=False) as pred:
            arrays["teacher_xy"] = pred["xy"].copy()
    arrays["images"] = images
    write_cache(args.output, arrays)
    print(f"Validated clip saved: {args.output}")


if __name__ == "__main__":
    main()