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

Function _load_selected

benchmark/models/r3/view.py:665–720  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

663 gui_status.value = f"viewer -> camera at frame {idx}"
664
665 def _load_selected():
666 name = gui_seq.value if gui_seq is not None else next(iter(runs))
667 path = runs[name]
668 state["playing"] = False
669 cached = state["cache"].pop(name, None)
670 if cached is not None:
671 state["cache"][name] = cached # bump to MRU
672 data = cached
673 gui_status.value = f"loaded {name} from cache"
674 else:
675 gui_status.value = f"loading {name} ..."
676 t0 = time.time()
677
678 def _on_progress(done, total):
679 gui_status.value = f"loading {name}: {done}/{total} frames"
680
681 try:
682 data = load_dense(
683 path,
684 conf_threshold_initial=args.initial_conf,
685 num_workers=int(args.load_workers),
686 progress_cb=_on_progress,
687 )
688 except Exception as e:
689 gui_status.value = f"load failed: {e}"
690 return
691 gui_status.value = f"loaded {name} in {time.time() - t0:.1f}s"
692 if int(args.cache_size) > 0:
693 state["cache"][name] = data
694 while len(state["cache"]) > int(args.cache_size):
695 state["cache"].popitem(last=False)
696 _clear_scene()
697 state["name"] = name
698 state["data"] = data
699 n_full = len(data["points"])
700 n_frames = len(data["cam_c2ws"])
701 try:
702 gui_n_points.max = max(10, n_full // 1000)
703 except Exception:
704 pass
705 try:
706 gui_frame.max = max(0, n_frames - 1)
707 gui_frame.value = 0
708 gui_pc_start.max = max(0, n_frames - 1)
709 gui_pc_end.max = max(0, n_frames - 1)
710 pc_start = max(0, min(int(args.pc_frame_start), n_frames - 1))
711 pc_end_arg = n_frames - 1 if int(args.pc_frame_end) < 0 else int(args.pc_frame_end)
712 pc_end = max(0, min(pc_end_arg, n_frames - 1))
713 gui_pc_start.value = pc_start
714 gui_pc_end.value = pc_end
715 except Exception:
716 pass
717 state["screenshot_dir"] = os.path.join(screenshot_root, name)
718 os.makedirs(state["screenshot_dir"], exist_ok=True)
719 _refresh_pointcloud()
720 _refresh_cameras()
721
722 # --- Keypoint helpers --------------------------------------------------------

Callers 2

_Function · 0.85
mainFunction · 0.85

Calls 4

load_denseFunction · 0.85
_clear_sceneFunction · 0.85
_refresh_pointcloudFunction · 0.85
_refresh_camerasFunction · 0.85

Tested by

no test coverage detected