Spaces:
Paused
Paused
Fix optional viser import and add Space caption metadata
Browse files- README.md +1 -0
- lingbot_map/vis/__init__.py +29 -41
README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
---
|
| 2 |
title: LingBot 3D
|
|
|
|
| 3 |
colorFrom: blue
|
| 4 |
colorTo: green
|
| 5 |
sdk: gradio
|
|
|
|
| 1 |
---
|
| 2 |
title: LingBot 3D
|
| 3 |
+
short_description: Streaming 3D scene reconstruction from short clips.
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
lingbot_map/vis/__init__.py
CHANGED
|
@@ -1,59 +1,47 @@
|
|
| 1 |
-
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
-
# All rights reserved.
|
| 3 |
-
#
|
| 4 |
-
# This source code is licensed under the license found in the
|
| 5 |
-
# LICENSE file in the root directory of this source tree.
|
| 6 |
-
|
| 7 |
"""
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
This module provides visualization utilities for 3D reconstruction results:
|
| 11 |
-
- PointCloudViewer: Interactive point cloud viewer with camera visualization
|
| 12 |
-
- viser_wrapper: Quick visualization wrapper for predictions
|
| 13 |
-
- predictions_to_glb: Export predictions to GLB 3D format
|
| 14 |
-
- Colorization and utility functions
|
| 15 |
-
|
| 16 |
-
Usage:
|
| 17 |
-
from lingbot_map.vis import PointCloudViewer, viser_wrapper, predictions_to_glb
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
# Quick visualization
|
| 24 |
-
viser_wrapper(predictions, port=8080)
|
| 25 |
-
|
| 26 |
-
# Export to GLB
|
| 27 |
-
scene = predictions_to_glb(predictions)
|
| 28 |
-
scene.export("output.glb")
|
| 29 |
"""
|
| 30 |
|
| 31 |
-
from
|
| 32 |
-
from lingbot_map.vis.viser_wrapper import viser_wrapper
|
| 33 |
-
from lingbot_map.vis.utils import CameraState, colorize, colorize_np, get_vertical_colorbar
|
| 34 |
-
from lingbot_map.vis.sky_segmentation import (
|
| 35 |
-
apply_sky_segmentation,
|
| 36 |
-
download_skyseg_model,
|
| 37 |
-
load_or_create_sky_masks,
|
| 38 |
-
segment_sky,
|
| 39 |
-
)
|
| 40 |
-
from lingbot_map.vis.glb_export import predictions_to_glb
|
| 41 |
|
| 42 |
__all__ = [
|
| 43 |
-
# Main viewer
|
| 44 |
"PointCloudViewer",
|
| 45 |
-
# Quick visualization
|
| 46 |
"viser_wrapper",
|
| 47 |
-
# GLB export
|
| 48 |
"predictions_to_glb",
|
| 49 |
-
# Utilities
|
| 50 |
"CameraState",
|
| 51 |
"colorize",
|
| 52 |
"colorize_np",
|
| 53 |
"get_vertical_colorbar",
|
| 54 |
-
# Sky segmentation
|
| 55 |
"apply_sky_segmentation",
|
| 56 |
"segment_sky",
|
| 57 |
"download_skyseg_model",
|
| 58 |
"load_or_create_sky_masks",
|
| 59 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
+
Visualization helpers for LingBot-Map.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
This package is imported by the Space only for GLB export. Keep imports lazy so
|
| 5 |
+
optional viewer dependencies like `viser` do not become hard runtime
|
| 6 |
+
requirements for the ZeroGPU Gradio app.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
"""
|
| 8 |
|
| 9 |
+
from importlib import import_module
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
__all__ = [
|
|
|
|
| 12 |
"PointCloudViewer",
|
|
|
|
| 13 |
"viser_wrapper",
|
|
|
|
| 14 |
"predictions_to_glb",
|
|
|
|
| 15 |
"CameraState",
|
| 16 |
"colorize",
|
| 17 |
"colorize_np",
|
| 18 |
"get_vertical_colorbar",
|
|
|
|
| 19 |
"apply_sky_segmentation",
|
| 20 |
"segment_sky",
|
| 21 |
"download_skyseg_model",
|
| 22 |
"load_or_create_sky_masks",
|
| 23 |
]
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def __getattr__(name):
|
| 27 |
+
if name == "predictions_to_glb":
|
| 28 |
+
return import_module("lingbot_map.vis.glb_export").predictions_to_glb
|
| 29 |
+
|
| 30 |
+
if name in {"apply_sky_segmentation", "segment_sky", "download_skyseg_model", "load_or_create_sky_masks"}:
|
| 31 |
+
return getattr(import_module("lingbot_map.vis.sky_segmentation"), name)
|
| 32 |
+
|
| 33 |
+
if name in {"CameraState", "colorize", "colorize_np", "get_vertical_colorbar"}:
|
| 34 |
+
return getattr(import_module("lingbot_map.vis.utils"), name)
|
| 35 |
+
|
| 36 |
+
if name in {"PointCloudViewer", "viser_wrapper"}:
|
| 37 |
+
try:
|
| 38 |
+
module_name = "lingbot_map.vis.point_cloud_viewer" if name == "PointCloudViewer" else "lingbot_map.vis.viser_wrapper"
|
| 39 |
+
return getattr(import_module(module_name), name)
|
| 40 |
+
except ModuleNotFoundError as exc:
|
| 41 |
+
if exc.name == "viser":
|
| 42 |
+
raise ModuleNotFoundError(
|
| 43 |
+
"`viser` is not installed. The Hugging Face Space uses GLB preview instead of the live Viser viewer."
|
| 44 |
+
) from exc
|
| 45 |
+
raise
|
| 46 |
+
|
| 47 |
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|