MCPcopy Create free account
hub / github.com/Robbyant/lingbot-map / BSSLoader

Class BSSLoader

benchmark/benchmark/core/loader.py:24–549  ·  view source on GitHub ↗

Loads data from a BSS artifact directory.

Source from the content-addressed store, hash-verified

22
23
24class BSSLoader:
25 """Loads data from a BSS artifact directory."""
26
27 def __init__(
28 self,
29 artifact: BSSArtifact,
30 resize_context: Optional[ResizeContext] = None,
31 context: object = None,
32 ):
33 """Initialize BSS loader.
34
35 Args:
36 artifact: BSSArtifact describing the directory to load from
37 resize_context: Optional ResizeContext controlling how images are resized.
38 If None, images are loaded at native resolution.
39 context: Optional dataset or method instance; used to dispatch
40 __load_{key}_file__ for custom key loading.
41 """
42 self.artifact = artifact
43 if not artifact.exists():
44 raise FileNotFoundError(f"BSS directory not found: {artifact}")
45 self.resize_context = resize_context
46 self.context = context
47
48 def copy(self) -> 'BSSLoader':
49 """Return a new BSSLoader with the same artifact, resize_context, and context."""
50 return BSSLoader(self.artifact, self.resize_context, self.context)
51
52 # ------------------------------------------------------------------
53 # Frame count / metadata helpers
54 # ------------------------------------------------------------------
55
56 def get_num_frames(self) -> int:
57 """Get the number of frames from .complete.json metadata.
58
59 Returns:
60 Number of frames in this scene
61
62 Raises:
63 ValueError: If .complete.json is missing or num_frames not found
64 """
65 metadata = self.artifact.read_metadata()
66 if metadata is None:
67 raise ValueError(f"Scene not complete or metadata missing: {self.artifact}")
68
69 num_frames = metadata.get('num_frames')
70 if num_frames is None:
71 raise ValueError(f"No num_frames in metadata: {self.artifact}")
72
73 return int(num_frames)
74
75 def get_frame_indices(self) -> List[int]:
76 """Get the original GT frame indices for stored frames.
77
78 For sparse SLAM outputs (K < N), returns the 'frame_index_map' list stored
79 in .complete.json, which maps each stored frame position to its original
80 GT frame index.
81

Callers 6

run_sceneFunction · 0.90
_rebuild_sceneMethod · 0.90
run_sceneFunction · 0.90
evaluateMethod · 0.90
process_sceneMethod · 0.90
copyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected