Download scripts/_apply_audit_fixes.py from LiYacheng/r4d-bench-qa: direct link, hf CLI and curl.
- Browser
- Download file 23.7 kB
-
https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_apply_audit_fixes.py
- Command line
-
hf download hf://datasets/LiYacheng/r4d-bench-qa/scripts/_apply_audit_fixes.py
-
curl -L -o _apply_audit_fixes.py https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_apply_audit_fixes.py
23.7 kB
| """ | |
| Apply RGB-verified audit fixes to scene track JSONs and query JSONs. | |
| This script is the single source of the curated decisions from the full-trace audit. | |
| It is intentionally explicit (no heuristics). Re-run after editing the FIXES below. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from collections import Counter | |
| from copy import deepcopy | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] | |
| SCENES = ROOT / "data" / "scenes" | |
| # scene_folder -> (track_file, query_file) | |
| SCENE_FILES = { | |
| "cut_lemon": ("cut_lemon.json", "cut_lemon_queries.json"), | |
| "espresso": ("espresso.json", "espresso_queries.json"), | |
| "keyboard": ("keyboard.json", "keyboard_queries.json"), | |
| "torchchocolate": ("torchchocolate.json", "torchchocolate_queries.json"), | |
| "cook_spinach": ("cook-spinach.json", "cook-spinach_queries.json"), | |
| "cut_roasted_beef": ("cut_roasted_beef.json", "cut_roasted_beef_queries.json"), | |
| "flame_salmon": ("flame_salmon.json", "flame_salmon_queries.json"), | |
| "sear_steak": ("sear_steak.json", "sear_steak_queries.json"), | |
| "flame_steak": ("flame_steak.json", "flame_steak_queries.json"), | |
| "split_cookie": ("split_cookie.json", "split_cookie_queries.json"), | |
| "americano": ("americano.json", "americano_queries.json"), | |
| "coffee_martini": ("coffee_martini.json", "coffee_martini_queries.json"), | |
| } | |
| def _vocab(tracks: list[dict]) -> list[str]: | |
| """Closed object vocabulary: category names; '(xN)' when multiple tracks share a category.""" | |
| counts = Counter(t["category"] for t in tracks) | |
| out = [] | |
| for cat, n in sorted(counts.items(), key=lambda kv: kv[0].lower()): | |
| out.append(f"{cat} (x{n})" if n > 1 else cat) | |
| return out | |
| def _set_track(tracks: list[dict], tid: str, **fields) -> None: | |
| for t in tracks: | |
| if t["track_id"] == tid: | |
| for k, v in fields.items(): | |
| if v is None and k in t: | |
| del t[k] | |
| elif v is not None: | |
| t[k] = v | |
| return | |
| raise KeyError(tid) | |
| def _set_query(queries: list[dict], qid: str, **fields) -> None: | |
| for q in queries: | |
| if q["query_id"] == qid: | |
| for k, v in fields.items(): | |
| if v is None and k in q: | |
| del q[k] | |
| elif v is not None: | |
| q[k] = v | |
| if "target_track_ids" in fields and fields["target_track_ids"] is not None: | |
| q["target_count"] = len(fields["target_track_ids"]) | |
| return | |
| raise KeyError(qid) | |
| def apply_cut_lemon(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "cut_lemon_1", | |
| description_en="The hand at the top of the image holds the knife and cuts the lemon.", | |
| description_zh="图像上方的手握着刀切割柠檬。", | |
| temporal_profile={ | |
| "holding_knife": [[0, 2360]], | |
| "cutting": [[0, 2200]], | |
| }, | |
| temporal_uncertain={"cutting": [[2201, 2359]]}, | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track( | |
| tracks, | |
| "cut_lemon_2", | |
| description_en="The hand on the right side of the image holds the lemon in place.", | |
| description_zh="图像右侧的手固定住柠檬。", | |
| ) | |
| _set_track( | |
| tracks, | |
| "cut_lemon_3", | |
| temporal_profile={"moving": [[0, 2360]], "cutting": [[0, 2200]]}, | |
| temporal_uncertain={"cutting": [[2201, 2359]]}, | |
| ) | |
| _set_track( | |
| tracks, | |
| "cut_lemon_4", | |
| temporal_profile={"whole": [[0, 1960]], "halves": [[2040, 2360]]}, | |
| ) | |
| _set_track( | |
| tracks, | |
| "cut_lemon_5", | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_query( | |
| queries, | |
| "cut_lemon_q3", | |
| text_en="The hand at the top of the image that is holding the knife.", | |
| text_zh="图像上方握着刀的手。", | |
| ) | |
| _set_query( | |
| queries, | |
| "cut_lemon_q4", | |
| text_en="All objects that physically move during the video.", | |
| text_zh="视频中发生物理移动的所有物体。", | |
| target_track_ids=["cut_lemon_1", "cut_lemon_2", "cut_lemon_3", "cut_lemon_4"], | |
| ) | |
| _set_query( | |
| queries, | |
| "cut_lemon_q5", | |
| text_en="The hand at the top of the image and the knife, while they are cutting the lemon.", | |
| text_zh="正在切割柠檬的图像上方的手和刀。", | |
| ) | |
| def apply_espresso(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "espresso_1", | |
| description_en="The glass cup remains stationary while coffee pours in; it goes from empty to filled.", | |
| description_zh="玻璃杯保持静止,咖啡注入后由空变为已注满。", | |
| temporal_profile={ | |
| "static": [[0, 775]], | |
| # RGB (user-verified): machine stream into the cup from f340. | |
| # Earlier scale ticks are drips onto the scale, not liquid in the cup. | |
| "empty": [[0, 339]], | |
| "filling": [[340, 710]], | |
| "filled": [[720, 775]], | |
| }, | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track( | |
| tracks, | |
| "espresso_2", | |
| description_en="The electronic scale remains stationary; displayed weight increases while coffee is poured. (GT mask excludes the glass cup / espresso_1.)", | |
| description_zh="电子秤保持静止;倒咖啡时显示重量增加。(真值掩码不含玻璃杯 / espresso_1。)", | |
| temporal_profile={ | |
| "static": [[0, 775]], | |
| "weight_increasing": [[280, 730]], | |
| }, | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track(tracks, "espresso_3", unannotated_visible_frames=[]) | |
| _set_track(tracks, "espresso_4", unannotated_visible_frames=[]) | |
| _set_track(tracks, "espresso_5", unannotated_visible_frames=[]) | |
| _set_track(tracks, "espresso_6", unannotated_visible_frames=[]) | |
| _set_query( | |
| queries, | |
| "espresso_q3", | |
| expected_temporal_anchor="filled", | |
| text_en="The glass cup after the coffee has finished pouring into it.", | |
| text_zh="咖啡注入完成后的玻璃杯。", | |
| ) | |
| _set_query( | |
| queries, | |
| "espresso_q7", | |
| expected_temporal_anchor="weight_increasing", | |
| text_en="The electronic scale whose displayed weight is increasing.", | |
| text_zh="显示重量正在增加的电子秤。", | |
| ) | |
| def apply_keyboard(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "keyboard_2", | |
| description_en="The hand at the lower left of the image types on the keyboard.", | |
| description_zh="图像左下方的手敲击键盘。", | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track( | |
| tracks, | |
| "keyboard_3", | |
| description_en="The hand at the upper right of the image types on the keyboard.", | |
| description_zh="图像右上方的手敲击键盘。", | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track(tracks, "keyboard_4", unannotated_visible_frames=[]) | |
| _set_track(tracks, "keyboard_5", unannotated_visible_frames=[]) | |
| _set_query( | |
| queries, | |
| "keyboard_q1", | |
| text_en="The hand at the lower left of the image while it is typing on the keyboard.", | |
| text_zh="正在键盘上打字、位于图像左下方的手。", | |
| ) | |
| def apply_torchchocolate(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "torchchocolate_1", | |
| is_static=False, | |
| description_en="The hand on the left side of the image holds the torch and aims its flame at the chocolate.", | |
| description_zh="图像左侧的手握持喷枪,将火焰对准巧克力。", | |
| temporal_profile={"holding_torch": [[0, 690]]}, | |
| ) | |
| _set_track( | |
| tracks, | |
| "torchchocolate_2", | |
| is_static=False, | |
| description_en="The hand on the right side of the image rests on the counter.", | |
| description_zh="图像右侧的手搭放在台面上。", | |
| temporal_profile={"resting": [[0, 690]]}, | |
| ) | |
| _set_track( | |
| tracks, | |
| "torchchocolate_3", | |
| is_static=False, | |
| # RGB: flame on but chocolate still solid through f30; melting visible from f40. | |
| temporal_profile={"solid": [[0, 39]], "melting": [[40, 690]]}, | |
| temporal_uncertain=None, | |
| ) | |
| _set_track( | |
| tracks, | |
| "torchchocolate_4", | |
| is_static=False, # worn by moving person; not a stationary prop | |
| ) | |
| _set_track( | |
| tracks, | |
| "torchchocolate_6", | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_query( | |
| queries, | |
| "torchchocolate_q3", | |
| text_en="All objects that are not part of the person (body or clothing).", | |
| text_zh="不属于人物(身体或衣物)的所有物体。", | |
| target_track_ids=["torchchocolate_3", "torchchocolate_5", "torchchocolate_6"], | |
| ) | |
| _set_query( | |
| queries, | |
| "torchchocolate_q5", | |
| text_en="The hand on the right side of the image that holds the torch.", | |
| text_zh="图像右侧握着喷枪的手。", | |
| target_track_ids=[], | |
| note="C-query: the torch is held by the left-side hand (torchchocolate_1), not the right.", | |
| ) | |
| def apply_cook_spinach(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "cook-spinach_6", | |
| description_en=( | |
| "The hand on the right side of the image is mostly still; around frames 120–140 it " | |
| "reaches down toward the pot / stove knob, and at the end reaches right toward a small black pot." | |
| ), | |
| description_zh="图像右侧的手大多静止;约在第120–140帧向下伸向锅/炉灶旋钮,结尾再向右伸向一小黑锅。", | |
| temporal_profile={ | |
| "static": [[0, 100], [200, 280]], | |
| "moving": [[120, 140], [299, 299]], | |
| "reaching_to_pot": [[120, 140]], | |
| "adjusting_knob": [[120, 140]], | |
| }, | |
| ) | |
| _set_query( | |
| queries, | |
| "cook-spinach_q3", | |
| expected_temporal_anchor="reaching_to_pot", | |
| text_en="The hand while it is reaching toward the pot.", | |
| text_zh="正在伸向锅的手。", | |
| note=None, | |
| ) | |
| _set_query( | |
| queries, | |
| "cook-spinach_q6", | |
| target_track_ids=["cook-spinach_6"], | |
| query_type="A", | |
| requires_motion_understanding=True, | |
| expected_temporal_anchor="adjusting_knob", | |
| temporal_relation="during", | |
| distractor=None, | |
| note="User-verified: the right-side hand reaches down to the stove knob around f120–f140 (mostly occluded by tongs/pot rim).", | |
| ) | |
| def apply_cut_roasted_beef(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "cut_roasted_beef_2", | |
| description_en="The beef steak is already sliced at the start and continues to be cut.", | |
| description_zh="牛排在起始帧已切开,并持续被切割。", | |
| temporal_profile={"being_cut": [[0, 300]], "intact": [[0, 0]]}, | |
| note="intact=[[0,0]]: the first frame is the pre-cut reference; cutting continues from there.", | |
| unannotated_visible_frames=[], | |
| ) | |
| _set_track(tracks, "cut_roasted_beef_7", is_static=False) | |
| _set_track(tracks, "cut_roasted_beef_8", unannotated_visible_frames=[]) | |
| _set_track(tracks, "cut_roasted_beef_10", is_static=False) | |
| _set_query( | |
| queries, | |
| "cut_roasted_beef_q2", | |
| note="Anchored on intact=[[0,0]]; only the first frame is positive, later frames are black.", | |
| ) | |
| _set_query( | |
| queries, | |
| "cut_roasted_beef_q4", | |
| target_track_ids=["cut_roasted_beef_1", "cut_roasted_beef_5", "cut_roasted_beef_9"], | |
| text_en="All objects that are completely motionless throughout the entire video.", | |
| text_zh="在整个视频中完全静止的所有物体。", | |
| ) | |
| def apply_flame_salmon(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "flame_salmon_2", | |
| is_static=False, | |
| description_en="The pot with salmon is seared by the torch; the pot itself is shifted/tilted during searing.", | |
| description_zh="装有三文鱼的锅被喷枪炙烤;炙烤过程中锅本身会被挪动/倾斜。", | |
| ) | |
| _set_track( | |
| tracks, | |
| "flame_salmon_5", | |
| is_static=False, | |
| description_en="The hand on the right side of the image grips the pan handle but drifts slightly.", | |
| description_zh="图像右侧的手握着锅柄,但有轻微漂移。", | |
| ) | |
| _set_query( | |
| queries, | |
| "flame_salmon_q4", | |
| # Pot (2) and both hands move; only green book + window stay put (Neu3D static camera). | |
| target_track_ids=["flame_salmon_3", "flame_salmon_8"], | |
| text_en="All objects that do not change position at any time.", | |
| text_zh="在任何时刻都不改变位置的所有物体。", | |
| note="Excludes pot and hands: RGB shows the pot is shifted/tilted while searing; hands move.", | |
| ) | |
| def apply_sear_steak(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "sear_steak_6", | |
| is_static=False, | |
| description_en="The hand on the right side of the image rests on the pan's right side but moves.", | |
| description_zh="图像右侧的手搭在锅右侧,但仍有移动。", | |
| ) | |
| _set_track(tracks, "sear_steak_7", unannotated_visible_frames=[]) | |
| _set_track( | |
| tracks, | |
| "sear_steak_8", | |
| temporal_profile={ | |
| "idle_above_pot": [[0, 100]], | |
| "nudging_steak": [[100, 180]], | |
| "lifting_steak": [[180, 280]], | |
| "holding_upright": [[299, 299]], | |
| }, | |
| ) | |
| # Query text must not leak frame numbers; temporal windows live in track profiles only. | |
| _set_query( | |
| queries, | |
| "sear_steak_q1", | |
| text_en="The tongs while they are nudging the steak to reposition it.", | |
| text_zh="正在轻推牛排以调整其位置的夹子。", | |
| ) | |
| _set_query( | |
| queries, | |
| "sear_steak_q2", | |
| text_en="The pot with beef steak at the final frame, when the steak is held upright by the tongs.", | |
| text_zh="在最后一帧牛排被夹子夹起竖立时的装有牛排的锅。", | |
| expected_temporal_anchor="lifted_and_upright", | |
| ) | |
| _set_query( | |
| queries, | |
| "sear_steak_q3", | |
| text_en="The hand on the left side of the image before it makes any contact with the steak.", | |
| text_zh="在与牛排接触前、位于图像左侧的手。", | |
| ) | |
| _set_query( | |
| queries, | |
| "sear_steak_q4", | |
| target_track_ids=["sear_steak_3", "sear_steak_4", "sear_steak_7"], | |
| text_en="All objects that never move throughout the entire video.", | |
| text_zh="在整个视频中从未移动的所有物体。", | |
| ) | |
| _set_query( | |
| queries, | |
| "sear_steak_q6", | |
| text_en="The hand that pours oil into the pot.", | |
| text_zh="向锅中倒油的手。", | |
| note="C-query: no oil-pouring hand appears in this video.", | |
| ) | |
| def apply_flame_steak(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "flame_steak_5", | |
| is_static=False, | |
| description_en="The hand on the right side of the image grips the pot handle but is not motionless.", | |
| description_zh="图像右侧的手握着锅柄,但并非完全静止。", | |
| ) | |
| _set_track( | |
| tracks, | |
| "flame_steak_8", | |
| temporal_profile={"emitting_flame_and_roaming": [[0, 300]]}, | |
| ) | |
| _set_query( | |
| queries, | |
| "flame_steak_q4", | |
| target_track_ids=["flame_steak_1", "flame_steak_3", "flame_steak_6", "flame_steak_7"], | |
| text_en="All objects that remain completely still throughout the video.", | |
| text_zh="在整个视频中始终完全静止的所有物体。", | |
| ) | |
| _set_query( | |
| queries, | |
| "flame_steak_q5", | |
| text_en="The bowl of spinach on the left side of the image.", | |
| text_zh="图像左侧的菠菜碗。", | |
| target_track_ids=[], | |
| note="C-query: spinach bowl is on the right; real tongs exist next to the pot so old tongs C-query was invalid.", | |
| ) | |
| def apply_split_cookie(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "cookie_1", | |
| description_en="The upper hand in the image holds one side of the cookie.", | |
| description_zh="图像上方的手握住曲奇饼干一侧。", | |
| ) | |
| _set_track( | |
| tracks, | |
| "cookie_2", | |
| description_en="The lower hand in the image holds the other side of the cookie.", | |
| description_zh="图像下方的手握住曲奇饼干另一侧。", | |
| ) | |
| _set_track( | |
| tracks, | |
| "cookie_3", | |
| is_static=False, | |
| # User-verified: breaking starts ~f230; fully split into two parts at f330. | |
| # Boundaries are inclusive on purpose (f230–f330 overlap intact/breaking; f330 is in all three). | |
| temporal_profile={ | |
| "intact": [[0, 330]], | |
| "breaking": [[230, 330]], | |
| "broken_pieces": [[330, 537]], | |
| }, | |
| ) | |
| _set_query( | |
| queries, | |
| "split_cookie_q5", | |
| text_en="The black cookie on the wooden board.", | |
| text_zh="木板上的黑色曲奇饼干。", | |
| note="C-query: the cookie is a golden chocolate-chip cookie, not black.", | |
| ) | |
| def apply_americano(tracks, queries): | |
| _set_track( | |
| tracks, | |
| "americano_2", | |
| description_en="The glass cup stays on the tray while clear water darkens as coffee is poured in.", | |
| description_zh="玻璃杯留在托盘上,清水随咖啡倒入逐渐变深。", | |
| temporal_profile={ | |
| "static": [[0, 524]], | |
| "light_liquid": [[0, 130]], | |
| # RGB: stream clearly into the glass by ~f140; liquid still looks light through f130. | |
| # User-verified: no liquid leaves the metal cup from f420. | |
| "darkening": [[140, 410]], | |
| "fully_darkened": [[420, 524]], | |
| }, | |
| ) | |
| _set_track( | |
| tracks, | |
| "americano_3", | |
| description_en="The hand holds the metal cup and pours coffee into the glass.", | |
| description_zh="手握着金属杯并向玻璃杯倒咖啡。", | |
| # RGB: pour motion / stream begins ~f130 (f120 tilted, f130 flowing). | |
| temporal_profile={"holding": [[0, 520]], "pouring": [[130, 410]]}, | |
| unannotated_visible_frames=[], | |
| existence_interval=[0, 524], | |
| ) | |
| _set_track( | |
| tracks, | |
| "americano_4", | |
| temporal_profile={ | |
| "tilting": [[0, 410]], | |
| "pouring": [[130, 410]], | |
| }, | |
| temporal_uncertain=None, | |
| existence_interval=[0, 524], | |
| ) | |
| _set_query( | |
| queries, | |
| "americano_q1", | |
| text_en="The glass cup while coffee is being poured into it and the liquid inside is darkening.", | |
| text_zh="正在被倒入咖啡、杯中液体逐渐变深的玻璃杯。", | |
| note="While color is changing; positives use darkening [140,410] (RGB-calibrated; pour stops at f420).", | |
| ) | |
| _set_query( | |
| queries, | |
| "americano_q3", | |
| text_en="The hand while coffee is flowing out of the metal cup it holds.", | |
| text_zh="金属杯中正有咖啡流出时,握着该金属杯的手。", | |
| ) | |
| _set_query( | |
| queries, | |
| "americano_q8", | |
| text_en="The glass cup that is lifted off the tray during the video.", | |
| text_zh="视频中被从托盘上拿起的玻璃杯。", | |
| target_track_ids=[], | |
| note="C-query: glass stays on tray; the metal cup is what moves.", | |
| ) | |
| _set_query( | |
| queries, | |
| "americano_q10", | |
| text_en="The glass cup after the coffee has stopped pouring and the liquid has fully darkened.", | |
| text_zh="咖啡停止倒入、杯中液体完全变深之后的玻璃杯。", | |
| note="No separate liquid instance; positives use fully_darkened [420,524] (pour stops at f420).", | |
| ) | |
| def apply_coffee_martini(tracks, queries): | |
| # RGB glass crop: f0 no stream yet; f20 has a clear stream into the glass. | |
| # Prior [40,299] over-gated f20 (visible pour → black GT). | |
| for tid in ("coffee_martini_3", "coffee_martini_4", "coffee_martini_5"): | |
| tr = next(t for t in tracks if t["track_id"] == tid) | |
| tp = dict(tr.get("temporal_profile") or {}) | |
| # RGB: glass still empty with no stream at f0/f1/f20; pour visible from f40. | |
| if tid == "coffee_martini_3": | |
| tp["leaning_and_pouring"] = [[40, 299]] | |
| elif tid == "coffee_martini_4": | |
| tp["filling"] = [[40, 299]] | |
| else: | |
| tp["tilting_and_pouring"] = [[40, 299]] | |
| tr["temporal_profile"] = tp | |
| _set_query( | |
| queries, | |
| "coffee_martini_q3", | |
| text_en="The man while he is pouring coffee into the martini glass.", | |
| text_zh="正在将咖啡倒入马提尼酒杯时的男人。", | |
| temporal_relation="while", | |
| expected_temporal_anchor="leaning_and_pouring", | |
| ) | |
| _set_query( | |
| queries, | |
| "coffee_martini_q4", | |
| target_track_ids=[ | |
| "coffee_martini_1", | |
| "coffee_martini_4", | |
| "coffee_martini_6", | |
| "coffee_martini_7", | |
| ], | |
| text_en="All objects that remain completely motionless throughout the video.", | |
| text_zh="在整个视频中完全静止的所有物体。", | |
| note="Martini glass is static (~2.2px); included among motionless objects.", | |
| ) | |
| APPLIERS = { | |
| "cut_lemon": apply_cut_lemon, | |
| "espresso": apply_espresso, | |
| "keyboard": apply_keyboard, | |
| "torchchocolate": apply_torchchocolate, | |
| "cook_spinach": apply_cook_spinach, | |
| "cut_roasted_beef": apply_cut_roasted_beef, | |
| "flame_salmon": apply_flame_salmon, | |
| "sear_steak": apply_sear_steak, | |
| "flame_steak": apply_flame_steak, | |
| "split_cookie": apply_split_cookie, | |
| "americano": apply_americano, | |
| "coffee_martini": apply_coffee_martini, | |
| } | |
| def main(): | |
| for scene, (tf, qf) in SCENE_FILES.items(): | |
| td_path = SCENES / scene / tf | |
| qd_path = SCENES / scene / qf | |
| td = json.loads(td_path.read_text(encoding="utf-8")) | |
| qd = json.loads(qd_path.read_text(encoding="utf-8")) | |
| tracks = td["tracks"] | |
| queries = qd["queries"] if isinstance(qd, dict) else qd | |
| APPLIERS[scene](tracks, queries) | |
| vocab = _vocab(tracks) | |
| td["object_vocabulary"] = vocab | |
| for q in queries: | |
| q["object_vocabulary"] = deepcopy(vocab) | |
| # document convention on every query | |
| q.setdefault( | |
| "vocabulary_note", | |
| "In this scene, words like 'objects' / 'everything' refer only to the " | |
| "closed object_vocabulary (annotated categories), not unannotated items.", | |
| ) | |
| td_path.write_text(json.dumps(td, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| if isinstance(qd, dict): | |
| qd["queries"] = queries | |
| qd["object_vocabulary"] = vocab | |
| qd_path.write_text(json.dumps(qd, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| else: | |
| qd_path.write_text(json.dumps(queries, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") | |
| print(f"OK {scene}: {len(tracks)} tracks, {len(queries)} queries, vocab={vocab}") | |
| if __name__ == "__main__": | |
| main() | |