r4d-bench-qa / scripts /_missing.py
LiYacheng's picture
Fill unannotated_visible gaps: every query/frame has GT masks (part 24)
aa7e82c verified
Raw History Blame Contribute Delete
1.32 kB
"""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()