Make native Gaussian export resilient
Browse files
app.py
CHANGED
|
@@ -57,7 +57,7 @@ from validate_manifest import validate_manifest
|
|
| 57 |
|
| 58 |
MODEL_ID = os.getenv("SIMAM3D_DEPTH_MODEL", "depth-anything/Depth-Anything-V2-Small-hf")
|
| 59 |
DA3_MODEL_ID = os.getenv("SIMAM3D_DA3_MODEL", "depth-anything/DA3NESTED-GIANT-LARGE-1.1")
|
| 60 |
-
SIMAM3D_VERSION = "0.4.
|
| 61 |
MANIFEST_SCHEMA_VERSION = 3
|
| 62 |
OUTPUT_DIR = Path("output")
|
| 63 |
MAX_VIEWS = int(os.getenv("SIMAM3D_MAX_VIEWS", "8"))
|
|
@@ -733,14 +733,23 @@ def generate(image: Image.Image, extra_files, backend: str, guess: str, demo_mod
|
|
| 733 |
fused_path, run_id, fused_weights, fused_source_views, fused_source_masks
|
| 734 |
)
|
| 735 |
gaussian_source = "fused_point_initialization"
|
|
|
|
| 736 |
direct_gaussian_count = 0
|
| 737 |
direct_gaussian_exported_count = 0
|
| 738 |
if da3_prediction is not None:
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 744 |
npz_path = save_prediction_npz(depth, confidence, extrinsics, intrinsics, run_id)
|
| 745 |
uncertainty = reveal_uncertainty(depth[0], confidence[0])
|
| 746 |
depth_lighting = estimate_depth_light(depth[0], np.asarray(images[0].resize(depth[0].shape[::-1], Image.Resampling.LANCZOS)))
|
|
@@ -792,6 +801,7 @@ def generate(image: Image.Image, extra_files, backend: str, guess: str, demo_mod
|
|
| 792 |
"gaussian_source": gaussian_source,
|
| 793 |
"direct_gaussian_count": direct_gaussian_count,
|
| 794 |
"direct_gaussian_exported_count": direct_gaussian_exported_count,
|
|
|
|
| 795 |
"gaussian_export_max_points": GAUSSIAN_MAX_POINTS,
|
| 796 |
"da3_process_res": DA3_PROCESS_RES,
|
| 797 |
"fused_point_count": fusion_stats["point_count"],
|
|
|
|
| 57 |
|
| 58 |
MODEL_ID = os.getenv("SIMAM3D_DEPTH_MODEL", "depth-anything/Depth-Anything-V2-Small-hf")
|
| 59 |
DA3_MODEL_ID = os.getenv("SIMAM3D_DA3_MODEL", "depth-anything/DA3NESTED-GIANT-LARGE-1.1")
|
| 60 |
+
SIMAM3D_VERSION = "0.4.5"
|
| 61 |
MANIFEST_SCHEMA_VERSION = 3
|
| 62 |
OUTPUT_DIR = Path("output")
|
| 63 |
MAX_VIEWS = int(os.getenv("SIMAM3D_MAX_VIEWS", "8"))
|
|
|
|
| 733 |
fused_path, run_id, fused_weights, fused_source_views, fused_source_masks
|
| 734 |
)
|
| 735 |
gaussian_source = "fused_point_initialization"
|
| 736 |
+
direct_gaussian_error = None
|
| 737 |
direct_gaussian_count = 0
|
| 738 |
direct_gaussian_exported_count = 0
|
| 739 |
if da3_prediction is not None:
|
| 740 |
+
try:
|
| 741 |
+
direct_result = direct_da3_gaussian_ply(da3_prediction, run_id)
|
| 742 |
+
if direct_result is not None:
|
| 743 |
+
direct_path, direct_gaussian_count, direct_gaussian_exported_count = direct_result
|
| 744 |
+
gaussian_path = direct_path
|
| 745 |
+
gaussian_source = "da3_direct"
|
| 746 |
+
except (RuntimeError, TypeError, ValueError) as exc:
|
| 747 |
+
direct_gaussian_error = f"{type(exc).__name__}: {exc}"
|
| 748 |
+
print(
|
| 749 |
+
f"Simam3D native Gaussian export unavailable; using fused initialization: {exc}",
|
| 750 |
+
flush=True,
|
| 751 |
+
)
|
| 752 |
+
gr.Warning("Native DA3 Gaussian export was unavailable; exported fused Gaussian initialization instead.")
|
| 753 |
npz_path = save_prediction_npz(depth, confidence, extrinsics, intrinsics, run_id)
|
| 754 |
uncertainty = reveal_uncertainty(depth[0], confidence[0])
|
| 755 |
depth_lighting = estimate_depth_light(depth[0], np.asarray(images[0].resize(depth[0].shape[::-1], Image.Resampling.LANCZOS)))
|
|
|
|
| 801 |
"gaussian_source": gaussian_source,
|
| 802 |
"direct_gaussian_count": direct_gaussian_count,
|
| 803 |
"direct_gaussian_exported_count": direct_gaussian_exported_count,
|
| 804 |
+
"direct_gaussian_error": direct_gaussian_error,
|
| 805 |
"gaussian_export_max_points": GAUSSIAN_MAX_POINTS,
|
| 806 |
"da3_process_res": DA3_PROCESS_RES,
|
| 807 |
"fused_point_count": fusion_stats["point_count"],
|