MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / save_scene_inputs

Function save_scene_inputs

benchmark/utils/visualization.py:344–367  ·  view source on GitHub ↗

Save the scene's input images to inputs_dir/ /. Each frame is exported as a PNG, with the filename containing the original frame_index for easy lookup in the source dataset. Args: scene: dict from BenchmarkDataset inputs_dir: parent directory; the function will cre

(scene, inputs_dir)

Source from the content-addressed store, hash-verified

342
343
344def save_scene_inputs(scene, inputs_dir):
345 """Save the scene&#x27;s input images to inputs_dir/<scene_id>/.
346
347 Each frame is exported as a PNG, with the filename containing the original frame_index for easy lookup in the source dataset.
348
349 Args:
350 scene: dict from BenchmarkDataset
351 inputs_dir: parent directory; the function will create a <scene_id>/ subdirectory inside it
352 """
353 from PIL import Image
354
355 scene_id = scene["scene_id"]
356 images_raw = scene["images_raw"] # (N, 3, H, W) float in [0, 1]
357 frame_indices = scene.get("frame_indices") or list(range(len(images_raw)))
358
359 out_dir = os.path.join(inputs_dir, scene_id)
360 os.makedirs(out_dir, exist_ok=True)
361
362 arr = (images_raw.detach().cpu().numpy() * 255.0).clip(0, 255).astype(np.uint8)
363 arr = np.transpose(arr, (0, 2, 3, 1)) # (N, H, W, 3)
364 for i, fidx in enumerate(frame_indices):
365 Image.fromarray(arr[i]).save(
366 os.path.join(out_dir, f"frame_{int(fidx):06d}.png")
367 )
368
369
370def visualize_gt(scene, output_dir):

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 2

saveMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected