Spaces:
Running
Running
| """ | |
| Visualization helpers for LingBot-Map. | |
| This package is imported by the Space only for GLB export. Keep imports lazy so | |
| optional viewer dependencies like `viser` do not become hard runtime | |
| requirements for the ZeroGPU Gradio app. | |
| """ | |
| from importlib import import_module | |
| __all__ = [ | |
| "PointCloudViewer", | |
| "viser_wrapper", | |
| "predictions_to_glb", | |
| "CameraState", | |
| "colorize", | |
| "colorize_np", | |
| "get_vertical_colorbar", | |
| "apply_sky_segmentation", | |
| "segment_sky", | |
| "download_skyseg_model", | |
| "load_or_create_sky_masks", | |
| ] | |
| def __getattr__(name): | |
| if name == "predictions_to_glb": | |
| return import_module("lingbot_map.vis.glb_export").predictions_to_glb | |
| if name in {"apply_sky_segmentation", "segment_sky", "download_skyseg_model", "load_or_create_sky_masks"}: | |
| return getattr(import_module("lingbot_map.vis.sky_segmentation"), name) | |
| if name in {"CameraState", "colorize", "colorize_np", "get_vertical_colorbar"}: | |
| return getattr(import_module("lingbot_map.vis.utils"), name) | |
| if name in {"PointCloudViewer", "viser_wrapper"}: | |
| try: | |
| module_name = "lingbot_map.vis.point_cloud_viewer" if name == "PointCloudViewer" else "lingbot_map.vis.viser_wrapper" | |
| return getattr(import_module(module_name), name) | |
| except ModuleNotFoundError as exc: | |
| if exc.name == "viser": | |
| raise ModuleNotFoundError( | |
| "`viser` is not installed. The Hugging Face Space uses GLB preview instead of the live Viser viewer." | |
| ) from exc | |
| raise | |
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | |