Download scripts/_missing.py from LiYacheng/r4d-bench-qa: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_missing.py
- Command line
-
hf download hf://datasets/LiYacheng/r4d-bench-qa/scripts/_missing.py
-
curl -L -o _missing.py https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_missing.py
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() | |