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.
0269
1"""Adapt hypothesis modules' build_spatial_code() calling convention across formats.2 3Mirrors symbolic/adapters.py's job (absorb a spatial-code schema difference behind one call),4but the difference handled here is in the HYPOTHESIS MODULE ITSELF, not the on-disk JSON: each5file under experiments/hypotheses/ is a full standalone fork of encoder/geometric.py.6 7- Older hypotheses were forked before the compact schema existed and expose a single-arg8 build_spatial_code(scene) that always builds the "explicit" answer-oriented schema.9- Newer hypotheses (forked from the current encoder/geometric.py, which already supports both10 schemas from one function) expose build_spatial_code(scene, spatial_code_format="explicit"),11 matching encoder/geometric.py's own real entry point.12 13experiments/run.py calls build() below instead of the hypothesis module directly, so callers14never need to know which style a given hypothesis file uses.15"""16 17from __future__ import annotations18 19import inspect20from types import ModuleType21 22from experiments.config import SPATIAL_CODE_FORMATS, validate_spatial_code_format23 24 25def supports_compact(hypothesis_module: ModuleType) -> bool:26 """Whether this hypothesis module's build_spatial_code() accepts a format argument."""27 params = inspect.signature(hypothesis_module.build_spatial_code).parameters28 return len(params) >= 229 30 31def build(hypothesis_module: ModuleType, scene, spatial_code_format: str = "explicit"):32 """Build one spatial code from a loaded hypothesis module, in the requested format.33 34 Raises ValueError if an "explicit"-only (older-style) hypothesis is asked to build35 "compact" -- that hypothesis genuinely cannot produce that schema, so failing loudly here36 is preferable to silently building the wrong format.37 """38 validate_spatial_code_format(spatial_code_format)39 if supports_compact(hypothesis_module):40 return hypothesis_module.build_spatial_code(scene, spatial_code_format)41 if spatial_code_format != "explicit":42 raise ValueError(43 f"{hypothesis_module.__name__} only supports the 'explicit' spatial-code "44 f"format (its build_spatial_code() takes a single scene argument); requested "45 f"{spatial_code_format!r}"46 )47 return hypothesis_module.build_spatial_code(scene)48 49 50__all__ = ["SPATIAL_CODE_FORMATS", "supports_compact", "build"]51 