File size: 1,323 Bytes
aa7e82c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""For every scene/track list the COCO frames where the track has no annotation."""
import json
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from scripts.predictions_ground_truth import SCENES_CONFIG, frame_number_from_coco_image


def main():
    for cfg in SCENES_CONFIG:
        scene = cfg["folder"]
        sd = ROOT / "data/scenes" / scene
        coco = json.loads((sd / cfg["annot_file"]).read_text(encoding="utf-8"))
        amap = json.loads((sd / "annotation_track_map.json").read_text(encoding="utf-8"))["assignments"]
        tracks = [t["track_id"] for t in json.loads((sd / cfg["track_file"]).read_text(encoding="utf-8"))["tracks"]]
        fid_of = {im["id"]: int(frame_number_from_coco_image(im)) for im in coco["images"]}
        have = {t: set() for t in tracks}
        for a in coco["annotations"]:
            t = amap.get(str(a["id"]))
            if t:
                have[t].add(fid_of[a["image_id"]])
        allf = sorted(fid_of.values())
        print(f"#### {scene} ({len(allf)} frames)")
        for t in tracks:
            miss = [f for f in allf if f not in have[t]]
            if miss:
                print(f"  {t}: {len(miss)} missing -> {miss}")


if __name__ == "__main__":
    main()