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

Function visualize_scene

benchmark/utils/visualization.py:399–438  ·  view source on GitHub ↗

Save the GT and predicted point clouds for one scene as GLB files. GT visualization uses the unified visualize_gt(); prediction visualization is delegated to adapter.visualize_prediction() (customizable per model). Args: scene: dict from BenchmarkDataset predictions: di

(scene, predictions, adapter,
                    gt_dir=None, pred_dir=None, output_dir=None,
                    z_far=None, vis_conf_percent=50.0)

Source from the content-addressed store, hash-verified

397
398
399def visualize_scene(scene, predictions, adapter,
400 gt_dir=None, pred_dir=None, output_dir=None,
401 z_far=None, vis_conf_percent=50.0):
402 """Save the GT and predicted point clouds for one scene as GLB files.
403
404 GT visualization uses the unified visualize_gt();
405 prediction visualization is delegated to adapter.visualize_prediction() (customizable per model).
406
407 Args:
408 scene: dict from BenchmarkDataset
409 predictions: dict from adapter.predict()
410 adapter: ModelAdapter instance
411 gt_dir: GT GLB output directory
412 pred_dir: Pred GLB output directory
413 output_dir: legacy-interface compatibility; if gt_dir/pred_dir are unspecified, both use this directory
414 z_far: maximum depth filter (None = no filtering)
415 vis_conf_percent: filter out the lowest N% confidence points (0 = no filter, 50 = filter the lowest 50%)
416 """
417 if gt_dir is None:
418 gt_dir = output_dir
419 if pred_dir is None:
420 pred_dir = output_dir
421 os.makedirs(gt_dir, exist_ok=True)
422 os.makedirs(pred_dir, exist_ok=True)
423
424 # GT point cloud (shared by all models)
425 visualize_gt(scene, gt_dir)
426
427 # If the scene has a sky_mask, zero out the sky region in the predicted depth before visualization
428 sky_mask = scene.get('sky_mask') # (N, H, W) bool or None
429 if sky_mask is not None and 'pred_depth' in predictions:
430 pred_depth = predictions['pred_depth'].copy()
431 pred_depth[sky_mask] = 0
432 predictions = {**predictions, 'pred_depth': pred_depth}
433
434 # Predicted point cloud (delegated to each model's adapter)
435 adapter.visualize_prediction(
436 scene, predictions, pred_dir,
437 z_far=z_far, vis_conf_percent=vis_conf_percent,
438 )

Callers 2

mainFunction · 0.90
mainFunction · 0.90

Calls 4

visualize_gtFunction · 0.85
copyMethod · 0.80
getMethod · 0.45
visualize_predictionMethod · 0.45

Tested by

no test coverage detected