AntonioJun/workspace
Spatial Code VSI-Bench Workspace This workspace evaluates VSI-Bench question answering with several input regimes: raw video frames, perceived spatial codes from SAM3 + Depth Anything 3 caches, ground-truth spatial codes from dataset annotations, and a deterministic symbolic solver. The code is organized so important outputs are reproducible from fixed inputs, fixed packages, fixed model checkpoints, and fixed SAM3/DA3 caches. The repository intentionally separates three… See the full description on the dataset page: https://huggingface.co/datasets/AntonioJun/workspace.
0264
1"""Build and write one final spatial-code JSON file per scene."""2 3from __future__ import annotations4 5import os6 7from encoder import config8from encoder import geometric as geometry_math9from encoder import run as perceive10 11 12def build_spatial_code_for(13 scene,14 depth,15 input_selection,16 tracking,17 frame_count=config.FRAMES_PER_VIDEO,18 rebuild=False,19 video=False,20 da3_path=None,21 sam3_path=None,22):23 """Build a spatial code from cached or newly adapted scene geometry."""24 if video:25 input_selection = config.VIDEO_INPUT_SELECTION26 kwargs = {"video": video}27 if da3_path is not None:28 kwargs["da3_path"] = da3_path29 if sam3_path is not None:30 kwargs["sam3_path"] = sam3_path31 geometry, how = perceive.cache_or_load(32 scene, depth, input_selection, tracking, frame_count, rebuild, **kwargs33 )34 code, *_ = geometry_math.build_spatial_code(geometry, "explicit")35 return code, how36 37 38def write_spatial_code_for(39 scene,40 depth,41 input_selection,42 tracking,43 frame_count=config.FRAMES_PER_VIDEO,44 rebuild=False,45 video=False,46 da3_path=None,47 sam3_path=None,48):49 """Build and write one scene's spatial-code JSON."""50 if video:51 input_selection = config.VIDEO_INPUT_SELECTION52 code, how = build_spatial_code_for(53 scene,54 depth,55 input_selection,56 tracking,57 frame_count,58 rebuild,59 video,60 da3_path,61 sam3_path,62 )63 path = config.spatial_code_path(64 scene,65 depth,66 input_selection,67 tracking,68 frame_count,69 "explicit",70 )71 os.makedirs(os.path.dirname(path), exist_ok=True)72 geometry_math.dump_spatial_code(code, path)73 return code, how, path74 