Spaces:
Paused
Paused
GitHub Actions commited on
Commit ·
a4f876a
1
Parent(s): 0d1fbc6
Deploy from GitHub commit feae62fa5b6d65b6bfe64ecd37fd85011bd7fb99
Browse files- app.py +297 -11
- requirements-gpu-cu126.txt +2 -0
- verify_live_frontend.py +82 -0
- verify_live_smoke.py +4 -1
- verify_r1_moge_sim.py +140 -0
- visualizer.gpu.toml +4 -0
app.py
CHANGED
|
@@ -153,6 +153,30 @@ VISUALIZER_DATA_DIR = str(config_value(
|
|
| 153 |
"data_dir",
|
| 154 |
"data",
|
| 155 |
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 158 |
seg_processor = None
|
|
@@ -161,6 +185,7 @@ segmentation_backend = "segformer"
|
|
| 161 |
depth_processor = None
|
| 162 |
depth_model = None
|
| 163 |
intrinsic_models = None
|
|
|
|
| 164 |
|
| 165 |
|
| 166 |
def hf_offline() -> bool:
|
|
@@ -357,6 +382,227 @@ def estimate_depth(img: Image.Image, width: int, height: int):
|
|
| 357 |
return None
|
| 358 |
|
| 359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
# ---------------------------------------------------------------------------
|
| 361 |
# B4 — Shade Range Expansion
|
| 362 |
# Encode the shade multiplier using the actual brightness spread of the floor
|
|
@@ -569,14 +815,21 @@ def repair_intrinsic_floor_shading(
|
|
| 569 |
)
|
| 570 |
floor_lum = lum[floor]
|
| 571 |
if floor_lum.size:
|
| 572 |
-
# Continuous suspicion weight: 0 below the floor's
|
| 573 |
-
# percentile,
|
| 574 |
-
#
|
| 575 |
-
#
|
| 576 |
-
# in the PHOTO too, so they get zero weight by construction.
|
| 577 |
-
|
| 578 |
glare_thresh = max(232.0, float(np.percentile(floor_lum, 97.0)))
|
| 579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
suspicion[~floor] = 0.0
|
| 581 |
if float(suspicion.max()) > 0.5:
|
| 582 |
# Ambient field: normalized masked blur over the trusted floor,
|
|
@@ -1098,7 +1351,12 @@ def plane_homography_from_depth(
|
|
| 1098 |
return homography, plane
|
| 1099 |
|
| 1100 |
|
| 1101 |
-
def estimate_floor_plane(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1102 |
ys, xs = np.where(mask > 0)
|
| 1103 |
if len(xs) < 1000:
|
| 1104 |
return None, None
|
|
@@ -1212,6 +1470,25 @@ def estimate_floor_plane(mask: np.ndarray, img_np: np.ndarray, depth: np.ndarray
|
|
| 1212 |
H = cv2.getPerspectiveTransform(src, dst)
|
| 1213 |
homography = H.flatten().tolist()
|
| 1214 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1215 |
# R1-2 — geometry arbitration: when the trapezoid homography (real or
|
| 1216 |
# synthetic VP) is inconsistent with the measured 3D floor — the certified
|
| 1217 |
# metric-scale gates fail on it — prefer the analytic depth-plane
|
|
@@ -1922,11 +2199,20 @@ def build_segmentation_bundle(contents: bytes):
|
|
| 1922 |
print(f"[TIMING] Depth estimation took {time.perf_counter() - t0:.3f} seconds", flush=True)
|
| 1923 |
|
| 1924 |
t0 = time.perf_counter()
|
| 1925 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1926 |
if plane is not None:
|
| 1927 |
# R1-3 — physical plane scale; null on relative depth so the frontend
|
| 1928 |
-
# falls back to the heuristic repeat.
|
| 1929 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1930 |
# R1-4 v3 — rotation cue priority: the ORIGINAL floor's own lattice
|
| 1931 |
# outranks the wall direction (an installer matches the existing
|
| 1932 |
# floor), walls remain the fallback for lineless floors (carpet),
|
|
|
|
| 153 |
"data_dir",
|
| 154 |
"data",
|
| 155 |
))
|
| 156 |
+
# R1-5 — MoGe-2 point-map geometry (ported from main / Ali Osaid's work,
|
| 157 |
+
# adapted to the R1-2 plane contract): a true metric 3D point map with the
|
| 158 |
+
# model's own intrinsics replaces the pinhole f~w back-projection — exactly
|
| 159 |
+
# the rooms where the depth fit abstained fell to the distorting synthetic-VP
|
| 160 |
+
# trapezoid (2026-06-12 dataset, rooms 3/4). CUDA-only; any failure falls
|
| 161 |
+
# back to the depth path unchanged.
|
| 162 |
+
GEOMETRY_MODEL = str(config_value(
|
| 163 |
+
"GEOMETRY_MODEL",
|
| 164 |
+
"models",
|
| 165 |
+
"geometry_model",
|
| 166 |
+
"moge",
|
| 167 |
+
))
|
| 168 |
+
MOGE_MODEL_NAME = str(config_value(
|
| 169 |
+
"MOGE_MODEL_NAME",
|
| 170 |
+
"models",
|
| 171 |
+
"moge_model_name",
|
| 172 |
+
"Ruicheng/moge-2-vitl-normal",
|
| 173 |
+
))
|
| 174 |
+
ENABLE_MOGE_GEOMETRY = str(config_value(
|
| 175 |
+
"ENABLE_MOGE_GEOMETRY",
|
| 176 |
+
"runtime",
|
| 177 |
+
"enable_moge_geometry",
|
| 178 |
+
"0",
|
| 179 |
+
)).lower() in {"1", "true", "yes", "on"}
|
| 180 |
|
| 181 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 182 |
seg_processor = None
|
|
|
|
| 185 |
depth_processor = None
|
| 186 |
depth_model = None
|
| 187 |
intrinsic_models = None
|
| 188 |
+
moge_model = None # R1-5
|
| 189 |
|
| 190 |
|
| 191 |
def hf_offline() -> bool:
|
|
|
|
| 382 |
return None
|
| 383 |
|
| 384 |
|
| 385 |
+
# ---------------------------------------------------------------------------
|
| 386 |
+
# R1-5 — MoGe-2 point-map geometry (ported from main / Ali Osaid's work)
|
| 387 |
+
# ---------------------------------------------------------------------------
|
| 388 |
+
|
| 389 |
+
def _to_numpy(value):
|
| 390 |
+
if value is None:
|
| 391 |
+
return None
|
| 392 |
+
if isinstance(value, torch.Tensor):
|
| 393 |
+
return value.detach().float().cpu().numpy()
|
| 394 |
+
return np.asarray(value)
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def pixel_intrinsics_from_model(
|
| 398 |
+
intrinsics: np.ndarray | None, width: int, height: int
|
| 399 |
+
) -> np.ndarray:
|
| 400 |
+
"""MoGe reports normalized intrinsics (fx, cx in units of width; fy, cy
|
| 401 |
+
of height); convert to pixels. Fallback: the P0 pinhole convention."""
|
| 402 |
+
if intrinsics is None:
|
| 403 |
+
f = float(max(width, height) * 0.95)
|
| 404 |
+
return np.array(
|
| 405 |
+
[[f, 0, width / 2.0], [0, f, height / 2.0], [0, 0, 1.0]], np.float32
|
| 406 |
+
)
|
| 407 |
+
K = np.asarray(intrinsics, np.float32).copy()
|
| 408 |
+
if abs(float(K[0, 0])) < 10:
|
| 409 |
+
K[0, 0] *= width
|
| 410 |
+
K[0, 2] *= width
|
| 411 |
+
K[1, 1] *= height
|
| 412 |
+
K[1, 2] *= height
|
| 413 |
+
return K
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
def estimate_moge_geometry(img_np: np.ndarray):
|
| 417 |
+
"""Metric 3D point map (+ normals, intrinsics) from MoGe-2. Returns None
|
| 418 |
+
unless enabled and on CUDA — the caller's depth path is the fallback."""
|
| 419 |
+
global moge_model
|
| 420 |
+
if not ENABLE_MOGE_GEOMETRY or GEOMETRY_MODEL != "moge" or device.type != "cuda":
|
| 421 |
+
return None
|
| 422 |
+
try:
|
| 423 |
+
if moge_model is None:
|
| 424 |
+
print(f"Loading MoGe geometry model: {MOGE_MODEL_NAME} ...", flush=True)
|
| 425 |
+
from moge.model.v2 import MoGeModel
|
| 426 |
+
moge_model = MoGeModel.from_pretrained(MOGE_MODEL_NAME).to(device)
|
| 427 |
+
moge_model.eval()
|
| 428 |
+
print("MoGe geometry model loaded.", flush=True)
|
| 429 |
+
|
| 430 |
+
image_tensor = (
|
| 431 |
+
torch.from_numpy(img_np.astype(np.float32) / 255.0).permute(2, 0, 1).to(device)
|
| 432 |
+
)
|
| 433 |
+
with torch.inference_mode(), torch.autocast(device_type="cuda", dtype=torch.float16):
|
| 434 |
+
output = moge_model.infer(image_tensor)
|
| 435 |
+
|
| 436 |
+
points = _to_numpy(output.get("points"))
|
| 437 |
+
valid_mask = _to_numpy(output.get("mask"))
|
| 438 |
+
intrinsics = _to_numpy(output.get("intrinsics"))
|
| 439 |
+
if points is None or points.ndim != 3 or points.shape[2] != 3:
|
| 440 |
+
raise RuntimeError("MoGe did not return an HxWx3 point map.")
|
| 441 |
+
h, w = img_np.shape[:2]
|
| 442 |
+
if points.shape[:2] != (h, w):
|
| 443 |
+
points = cv2.resize(points, (w, h), interpolation=cv2.INTER_LINEAR)
|
| 444 |
+
if valid_mask is not None and valid_mask.shape[:2] != (h, w):
|
| 445 |
+
valid_mask = cv2.resize(
|
| 446 |
+
valid_mask.astype(np.uint8), (w, h), interpolation=cv2.INTER_NEAREST
|
| 447 |
+
).astype(bool)
|
| 448 |
+
if valid_mask is None:
|
| 449 |
+
valid_mask = np.isfinite(points[:, :, 2]) & (points[:, :, 2] > 0)
|
| 450 |
+
return {
|
| 451 |
+
"provider": "moge-2",
|
| 452 |
+
"points": points.astype(np.float32),
|
| 453 |
+
"validMask": valid_mask.astype(bool),
|
| 454 |
+
"intrinsics": intrinsics.astype(np.float32) if intrinsics is not None else None,
|
| 455 |
+
}
|
| 456 |
+
except Exception as exc:
|
| 457 |
+
print(f"MoGe geometry estimation failed ({exc}); falling back to depth.", flush=True)
|
| 458 |
+
if device.type == "cuda":
|
| 459 |
+
torch.cuda.empty_cache()
|
| 460 |
+
return None
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
def plane_homography_from_moge(geometry, mask: np.ndarray, w: int, h: int):
|
| 464 |
+
"""R1-5 — analytic floor homography from the MoGe point map, same
|
| 465 |
+
contract as plane_homography_from_depth (R1-2): trimmed TLS plane fit,
|
| 466 |
+
metre-unit in-plane axes, H = inv(K @ [u v c]) — but P comes from the
|
| 467 |
+
model's metric point map and K from its own intrinsics, so no pinhole
|
| 468 |
+
f~w assumption. The scale self-check measures 3D-vs-plane pair
|
| 469 |
+
distances on the point map directly; a bad fit abstains rather than
|
| 470 |
+
shipping a wrong scale. Returns (homography_list, plane_dict) or None.
|
| 471 |
+
"""
|
| 472 |
+
if geometry is None or geometry.get("points") is None:
|
| 473 |
+
return None
|
| 474 |
+
points = geometry["points"]
|
| 475 |
+
if points.shape[:2] != (h, w):
|
| 476 |
+
return None
|
| 477 |
+
sel_mask = (mask > 0) & np.isfinite(points).all(axis=2) & (points[:, :, 2] > 0.05)
|
| 478 |
+
valid = geometry.get("validMask")
|
| 479 |
+
if valid is not None:
|
| 480 |
+
sel_mask &= valid
|
| 481 |
+
ys, xs = np.nonzero(sel_mask)
|
| 482 |
+
if len(xs) < 2000:
|
| 483 |
+
return None
|
| 484 |
+
rng = np.random.default_rng(7)
|
| 485 |
+
sel = rng.choice(len(xs), size=min(6000, len(xs)), replace=False)
|
| 486 |
+
x_f = xs[sel].astype(np.float64)
|
| 487 |
+
y_f = ys[sel].astype(np.float64)
|
| 488 |
+
P = points[ys[sel], xs[sel]].astype(np.float64)
|
| 489 |
+
|
| 490 |
+
# iteratively trimmed total-least-squares plane fit (mirrors R1-2)
|
| 491 |
+
keep = np.ones(len(P), bool)
|
| 492 |
+
n = np.array([0.0, -1.0, 0.0])
|
| 493 |
+
c = P.mean(axis=0)
|
| 494 |
+
for _ in range(4):
|
| 495 |
+
c = P[keep].mean(axis=0)
|
| 496 |
+
q = P[keep] - c
|
| 497 |
+
_, _, vt = np.linalg.svd(q, full_matrices=False)
|
| 498 |
+
n = vt[2]
|
| 499 |
+
resid = np.abs((P - c) @ n)
|
| 500 |
+
thr = max(float(np.percentile(resid[keep], 80)), 1e-4)
|
| 501 |
+
keep = resid <= thr
|
| 502 |
+
|
| 503 |
+
resid = np.abs((P - c) @ n)
|
| 504 |
+
med_z = float(np.median(P[:, 2]))
|
| 505 |
+
inliers = resid <= max(0.03, 0.025 * med_z)
|
| 506 |
+
if inliers.mean() < 0.6:
|
| 507 |
+
return None
|
| 508 |
+
c = P[inliers].mean(axis=0)
|
| 509 |
+
q = P[inliers] - c
|
| 510 |
+
_, _, vt = np.linalg.svd(q, full_matrices=False)
|
| 511 |
+
n = vt[2]
|
| 512 |
+
if n @ c > 0:
|
| 513 |
+
n = -n # face the camera
|
| 514 |
+
if n[1] > -0.5:
|
| 515 |
+
return None # wall-like fit, not a floor
|
| 516 |
+
|
| 517 |
+
u = np.cross(n, [0.0, 0.0, 1.0])
|
| 518 |
+
if np.linalg.norm(u) < 0.2:
|
| 519 |
+
u = np.cross(n, [0.0, 1.0, 0.0])
|
| 520 |
+
u /= np.linalg.norm(u)
|
| 521 |
+
v = np.cross(n, u)
|
| 522 |
+
v /= np.linalg.norm(v)
|
| 523 |
+
|
| 524 |
+
K = pixel_intrinsics_from_model(geometry.get("intrinsics"), w, h).astype(np.float64)
|
| 525 |
+
M = K @ np.stack([u, v, c], axis=1)
|
| 526 |
+
if abs(np.linalg.det(M)) < 1e-9:
|
| 527 |
+
return None
|
| 528 |
+
H = np.linalg.inv(M)
|
| 529 |
+
H = H / H[2, 2]
|
| 530 |
+
|
| 531 |
+
def to_plane(px, py):
|
| 532 |
+
den = H[2, 0] * px + H[2, 1] * py + H[2, 2]
|
| 533 |
+
return (
|
| 534 |
+
(H[0, 0] * px + H[0, 1] * py + H[0, 2]) / den,
|
| 535 |
+
(H[1, 0] * px + H[1, 1] * py + H[1, 2]) / den,
|
| 536 |
+
)
|
| 537 |
+
|
| 538 |
+
mx, my = float(np.median(x_f)), float(np.median(y_f))
|
| 539 |
+
a0, b0 = to_plane(mx, my)
|
| 540 |
+
a_dx, _ = to_plane(mx + 10, my)
|
| 541 |
+
_, b_dy = to_plane(mx, my + 10)
|
| 542 |
+
flip = np.diag([
|
| 543 |
+
-1.0 if a_dx - a0 < 0 else 1.0,
|
| 544 |
+
-1.0 if b_dy - b0 < 0 else 1.0,
|
| 545 |
+
1.0,
|
| 546 |
+
])
|
| 547 |
+
H = flip @ H
|
| 548 |
+
H = H / H[2, 2]
|
| 549 |
+
|
| 550 |
+
# scale self-check on the point map itself: random inlier pairs must
|
| 551 |
+
# measure the same in 3D and in plane space (metre units both sides)
|
| 552 |
+
Pi = P[inliers]
|
| 553 |
+
xi = x_f[inliers]
|
| 554 |
+
yi = y_f[inliers]
|
| 555 |
+
i = rng.integers(0, len(Pi), 4000)
|
| 556 |
+
j = rng.integers(0, len(Pi), 4000)
|
| 557 |
+
pairs = i != j
|
| 558 |
+
d3 = np.linalg.norm(Pi[i[pairs]] - Pi[j[pairs]], axis=1)
|
| 559 |
+
pa_i, pb_i = to_plane(xi, yi)
|
| 560 |
+
# re-evaluate through the flipped H
|
| 561 |
+
den_f = H[2, 0] * xi + H[2, 1] * yi + H[2, 2]
|
| 562 |
+
pa_i = (H[0, 0] * xi + H[0, 1] * yi + H[0, 2]) / den_f
|
| 563 |
+
pb_i = (H[1, 0] * xi + H[1, 1] * yi + H[1, 2]) / den_f
|
| 564 |
+
dp = np.hypot(
|
| 565 |
+
pa_i[i[pairs]] - pa_i[j[pairs]], pb_i[i[pairs]] - pb_i[j[pairs]]
|
| 566 |
+
)
|
| 567 |
+
far = dp > 0.2
|
| 568 |
+
if far.sum() < 200:
|
| 569 |
+
return None
|
| 570 |
+
ratios = d3[far] / np.maximum(dp[far], 1e-9)
|
| 571 |
+
med = float(np.median(ratios))
|
| 572 |
+
q1, q3 = np.percentile(ratios, 25), np.percentile(ratios, 75)
|
| 573 |
+
if not (0.85 <= med <= 1.15) or (q3 - q1) / max(med, 1e-9) > 0.35:
|
| 574 |
+
return None
|
| 575 |
+
|
| 576 |
+
# plane-space extent (percentile box, metres) — same sanity as R1-2
|
| 577 |
+
den_all = H[2, 0] * x_f + H[2, 1] * y_f + H[2, 2]
|
| 578 |
+
pa = (H[0, 0] * x_f + H[0, 1] * y_f + H[0, 2]) / den_all
|
| 579 |
+
pb = (H[1, 0] * x_f + H[1, 1] * y_f + H[1, 2]) / den_all
|
| 580 |
+
a1, a2 = float(np.percentile(pa, 1)), float(np.percentile(pa, 99))
|
| 581 |
+
b1, b2 = float(np.percentile(pb, 1)), float(np.percentile(pb, 99))
|
| 582 |
+
if not (0.8 <= a2 - a1 <= 30.0 and 0.8 <= b2 - b1 <= 60.0):
|
| 583 |
+
return None
|
| 584 |
+
|
| 585 |
+
Hinv = np.linalg.inv(H)
|
| 586 |
+
|
| 587 |
+
def to_img(ap, bp):
|
| 588 |
+
den_i = Hinv[2, 0] * ap + Hinv[2, 1] * bp + Hinv[2, 2]
|
| 589 |
+
return (
|
| 590 |
+
float(np.clip((Hinv[0, 0] * ap + Hinv[0, 1] * bp + Hinv[0, 2]) / den_i, 0, w - 1)),
|
| 591 |
+
float(np.clip((Hinv[1, 0] * ap + Hinv[1, 1] * bp + Hinv[1, 2]) / den_i, 0, h - 1)),
|
| 592 |
+
)
|
| 593 |
+
|
| 594 |
+
quad = [to_img(a1, b2), to_img(a2, b2), to_img(a2, b1), to_img(a1, b1)]
|
| 595 |
+
plane = {
|
| 596 |
+
"x": a1,
|
| 597 |
+
"y": b1,
|
| 598 |
+
"width": a2 - a1,
|
| 599 |
+
"height": b2 - b1,
|
| 600 |
+
"quad": [coord for pt in quad for coord in pt],
|
| 601 |
+
"geometrySource": "moge-plane", # R1-5 — vs depth-plane / VP trapezoid
|
| 602 |
+
}
|
| 603 |
+
return H.flatten().tolist(), plane
|
| 604 |
+
|
| 605 |
+
|
| 606 |
# ---------------------------------------------------------------------------
|
| 607 |
# B4 — Shade Range Expansion
|
| 608 |
# Encode the shade multiplier using the actual brightness spread of the floor
|
|
|
|
| 815 |
)
|
| 816 |
floor_lum = lum[floor]
|
| 817 |
if floor_lum.size:
|
| 818 |
+
# Continuous suspicion weight: 0 below the floor's 75th brightness
|
| 819 |
+
# percentile, saturating at a knee WELL BELOW the hard glare
|
| 820 |
+
# threshold (v2.1 — the v2 ramp only reached ~0.6 inside the blob,
|
| 821 |
+
# leaving a visible residual smudge on light tiles). Real shadows
|
| 822 |
+
# are dark in the PHOTO too, so they get zero weight by construction.
|
| 823 |
+
p75 = float(np.percentile(floor_lum, 75.0))
|
| 824 |
glare_thresh = max(232.0, float(np.percentile(floor_lum, 97.0)))
|
| 825 |
+
knee = p75 + 0.55 * max(glare_thresh - p75, 1e-3)
|
| 826 |
+
suspicion = np.clip((lum - p75) / max(knee - p75, 1e-3), 0.0, 1.0)
|
| 827 |
+
suspicion[~floor] = 0.0
|
| 828 |
+
# v2.1 — spread into the penumbra: the model's dark basin extends a
|
| 829 |
+
# little past the photo-bright core; a blurred copy carries the lift
|
| 830 |
+
# outward so the blob edge doesn't survive as a ring.
|
| 831 |
+
spread = cv2.GaussianBlur(suspicion, (0, 0), sigmaX=max(6.0, min(h, w) / 50.0))
|
| 832 |
+
suspicion = np.maximum(suspicion, np.clip(spread * 1.5, 0.0, 1.0))
|
| 833 |
suspicion[~floor] = 0.0
|
| 834 |
if float(suspicion.max()) > 0.5:
|
| 835 |
# Ambient field: normalized masked blur over the trusted floor,
|
|
|
|
| 1351 |
return homography, plane
|
| 1352 |
|
| 1353 |
|
| 1354 |
+
def estimate_floor_plane(
|
| 1355 |
+
mask: np.ndarray,
|
| 1356 |
+
img_np: np.ndarray,
|
| 1357 |
+
depth: np.ndarray | None = None,
|
| 1358 |
+
geometry: dict | None = None,
|
| 1359 |
+
):
|
| 1360 |
ys, xs = np.where(mask > 0)
|
| 1361 |
if len(xs) < 1000:
|
| 1362 |
return None, None
|
|
|
|
| 1470 |
H = cv2.getPerspectiveTransform(src, dst)
|
| 1471 |
homography = H.flatten().tolist()
|
| 1472 |
|
| 1473 |
+
# R1-5 — a confident MoGe point-map plane outranks both the trapezoid and
|
| 1474 |
+
# the pinhole depth fit: true metric points with the model's own
|
| 1475 |
+
# intrinsics, gated by its internal scale self-check. This is what fixes
|
| 1476 |
+
# the rooms whose trapezoid passed the consistency gates but still
|
| 1477 |
+
# carried the synthetic construction's distortion (dataset rooms 3/4).
|
| 1478 |
+
if geometry is not None:
|
| 1479 |
+
fitted = plane_homography_from_moge(geometry, mask, w, h)
|
| 1480 |
+
if fitted is not None:
|
| 1481 |
+
homography_m, plane_meta = fitted
|
| 1482 |
+
plane_meta["hullQuad"] = hull_quad_list
|
| 1483 |
+
plane_meta["vanishingPoint"] = vanishing_point
|
| 1484 |
+
plane_meta["vanishingPoint2"] = vanishing_point2
|
| 1485 |
+
plane_meta["defaultRotation"] = estimate_default_rotation(
|
| 1486 |
+
mask,
|
| 1487 |
+
np.asarray(homography_m, np.float64).reshape(3, 3),
|
| 1488 |
+
vanishing_point2,
|
| 1489 |
+
)
|
| 1490 |
+
return homography_m, plane_meta
|
| 1491 |
+
|
| 1492 |
# R1-2 — geometry arbitration: when the trapezoid homography (real or
|
| 1493 |
# synthetic VP) is inconsistent with the measured 3D floor — the certified
|
| 1494 |
# metric-scale gates fail on it — prefer the analytic depth-plane
|
|
|
|
| 2199 |
print(f"[TIMING] Depth estimation took {time.perf_counter() - t0:.3f} seconds", flush=True)
|
| 2200 |
|
| 2201 |
t0 = time.perf_counter()
|
| 2202 |
+
geometry = estimate_moge_geometry(img_np) # R1-5 — None unless enabled + CUDA
|
| 2203 |
+
if geometry is not None:
|
| 2204 |
+
print(f"[TIMING] MoGe geometry took {time.perf_counter() - t0:.3f} seconds", flush=True)
|
| 2205 |
+
|
| 2206 |
+
t0 = time.perf_counter()
|
| 2207 |
+
homography, plane = estimate_floor_plane(floor_mask, img_np, depth, geometry)
|
| 2208 |
if plane is not None:
|
| 2209 |
# R1-3 — physical plane scale; null on relative depth so the frontend
|
| 2210 |
+
# falls back to the heuristic repeat. The MoGe plane is metre-unit by
|
| 2211 |
+
# construction (its own scale self-check gates the fit).
|
| 2212 |
+
if plane.get("geometrySource") == "moge-plane":
|
| 2213 |
+
plane["metersPerUnit"] = 1.0
|
| 2214 |
+
else:
|
| 2215 |
+
plane["metersPerUnit"] = estimate_meters_per_unit(depth, floor_mask, homography, w, h)
|
| 2216 |
# R1-4 v3 — rotation cue priority: the ORIGINAL floor's own lattice
|
| 2217 |
# outranks the wall direction (an installer matches the existing
|
| 2218 |
# floor), walls remain the fallback for lineless floors (carpet),
|
requirements-gpu-cu126.txt
CHANGED
|
@@ -3,3 +3,5 @@
|
|
| 3 |
torch==2.7.0+cu126
|
| 4 |
torchvision==0.22.0+cu126
|
| 5 |
triton==3.3.0
|
|
|
|
|
|
|
|
|
| 3 |
torch==2.7.0+cu126
|
| 4 |
torchvision==0.22.0+cu126
|
| 5 |
triton==3.3.0
|
| 6 |
+
# R1-5 — MoGe-2 point-map geometry
|
| 7 |
+
git+https://github.com/microsoft/MoGe.git
|
verify_live_frontend.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""R0-4 — post-deploy FRONTEND gate.
|
| 2 |
+
|
| 3 |
+
Three test rounds were invalidated by a stale frontend (Vercel promote
|
| 4 |
+
skipped twice; an outdated URL once). This gate verifies the ARTIFACT the
|
| 5 |
+
testers actually load: fetch the canonical production URL, locate the built
|
| 6 |
+
bundle, and assert it carries the current engine's markers and points at the
|
| 7 |
+
right backend. Run it after every Vercel promote — a failure means testers
|
| 8 |
+
would be looking at old code.
|
| 9 |
+
|
| 10 |
+
Pure stdlib (no pip installs in CI).
|
| 11 |
+
|
| 12 |
+
Usage:
|
| 13 |
+
python verify_live_frontend.py [base_url]
|
| 14 |
+
# default: https://room-editor-9y3b.vercel.app
|
| 15 |
+
|
| 16 |
+
Exit 0 = the served frontend is current; non-zero = block/alert.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
import re
|
| 20 |
+
import sys
|
| 21 |
+
import urllib.request
|
| 22 |
+
|
| 23 |
+
CANONICAL_URL = "https://room-editor-9y3b.vercel.app"
|
| 24 |
+
BACKEND_HOST = "modventures-room-visualizer.hf.space"
|
| 25 |
+
|
| 26 |
+
# Marker inventory: object property names survive minification; function
|
| 27 |
+
# names do not. Keep one marker per shipped feature generation so a stale
|
| 28 |
+
# build is identifiable by WHICH markers are missing.
|
| 29 |
+
ENGINE_MARKERS = [
|
| 30 |
+
("defaultRotation", "P1-4 rotation consumption"),
|
| 31 |
+
("keepRug", "R3-3 rug toggle"),
|
| 32 |
+
("tileWidthM", "R1-3/R2-1 metric sizing"),
|
| 33 |
+
("groutFrac", "R2-3 procedural cells"),
|
| 34 |
+
("rugFlags", "R3-3 rug flags"),
|
| 35 |
+
("Classic Checkered", "catalog present"),
|
| 36 |
+
("Calacatta Marble", "R2-2 seamless pack (2026-06-12)"),
|
| 37 |
+
("viz2d/convert", "backend API wiring"),
|
| 38 |
+
(BACKEND_HOST, "points at the canonical backend"),
|
| 39 |
+
]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def fetch(url: str, timeout: int = 30) -> str:
|
| 43 |
+
req = urllib.request.Request(url, headers={"User-Agent": "verify-live-frontend"})
|
| 44 |
+
with urllib.request.urlopen(req, timeout=timeout) as r:
|
| 45 |
+
return r.read().decode("utf-8", errors="replace")
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def main() -> int:
|
| 49 |
+
base = sys.argv[1] if len(sys.argv) > 1 else CANONICAL_URL
|
| 50 |
+
print(f"frontend gate target: {base}", flush=True)
|
| 51 |
+
|
| 52 |
+
html = fetch(base)
|
| 53 |
+
ok = True
|
| 54 |
+
|
| 55 |
+
title = re.search(r"<title>([^<]*)</title>", html)
|
| 56 |
+
title_ok = bool(title) and "BAETES" in title.group(1)
|
| 57 |
+
print(f" [{'PASS' if title_ok else 'FAIL'}] title is the current app "
|
| 58 |
+
f"({title.group(1) if title else 'none'})")
|
| 59 |
+
ok &= title_ok
|
| 60 |
+
|
| 61 |
+
asset = re.search(r"assets/index-[A-Za-z0-9_-]+\.js", html)
|
| 62 |
+
if not asset:
|
| 63 |
+
print(" [FAIL] no built index-*.js asset referenced — not a Vite build?")
|
| 64 |
+
raise SystemExit("FRONTEND GATE FAILED")
|
| 65 |
+
print(f" bundle: {asset.group(0)}")
|
| 66 |
+
|
| 67 |
+
bundle = fetch(f"{base}/{asset.group(0)}", timeout=60)
|
| 68 |
+
for marker, why in ENGINE_MARKERS:
|
| 69 |
+
passed = marker in bundle
|
| 70 |
+
print(f" [{'PASS' if passed else 'FAIL'}] {marker} ({why})")
|
| 71 |
+
ok &= passed
|
| 72 |
+
|
| 73 |
+
if not ok:
|
| 74 |
+
print("\nFRONTEND GATE FAILED — the served bundle is stale or "
|
| 75 |
+
"mis-deployed. Did the Vercel production promote happen?")
|
| 76 |
+
return 1
|
| 77 |
+
print("\nFRONTEND GATE PASSED")
|
| 78 |
+
return 0
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
if __name__ == "__main__":
|
| 82 |
+
raise SystemExit(main())
|
verify_live_smoke.py
CHANGED
|
@@ -121,7 +121,10 @@ def main():
|
|
| 121 |
|
| 122 |
checks = [
|
| 123 |
("depthEnabled", meta.get("depthEnabled") is True),
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
| 125 |
("metersPerUnit in [0.5, 2.0]",
|
| 126 |
isinstance(plane.get("metersPerUnit"), (int, float))
|
| 127 |
and 0.5 <= plane["metersPerUnit"] <= 2.0),
|
|
|
|
| 121 |
|
| 122 |
checks = [
|
| 123 |
("depthEnabled", meta.get("depthEnabled") is True),
|
| 124 |
+
# R1-5 — either metric plane source is correct: moge-plane when the
|
| 125 |
+
# point-map fit passes its gates, depth-plane otherwise.
|
| 126 |
+
("geometrySource in {depth-plane, moge-plane}",
|
| 127 |
+
plane.get("geometrySource") in ("depth-plane", "moge-plane")),
|
| 128 |
("metersPerUnit in [0.5, 2.0]",
|
| 129 |
isinstance(plane.get("metersPerUnit"), (int, float))
|
| 130 |
and 0.5 <= plane["metersPerUnit"] <= 2.0),
|
verify_r1_moge_sim.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""R1-5 — MoGe point-map plane fit certification (CI-safe: synthetic point
|
| 2 |
+
map, no torch, no model).
|
| 3 |
+
|
| 4 |
+
A ground plane is constructed analytically: rays through a known camera K
|
| 5 |
+
intersect a tilted floor plane, giving a perfect metric point map. The only
|
| 6 |
+
thing under test is the REAL plane_homography_from_moge from app.py: it must
|
| 7 |
+
recover a metre-unit homography (1 m in the world measures 1.0 in plane
|
| 8 |
+
space), report geometrySource=moge-plane, honour the model's own intrinsics
|
| 9 |
+
(passed normalized, the MoGe convention), and abstain on wall-dominant fits,
|
| 10 |
+
noise, and missing geometry.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
import cv2 # noqa: F401 (the extracted code uses np only, cv2 kept for parity)
|
| 15 |
+
|
| 16 |
+
IMG_W, IMG_H = 640, 480
|
| 17 |
+
F_PX = 612.0 # deliberately NOT ~width: the old pinhole f~w guess would be wrong
|
| 18 |
+
|
| 19 |
+
# --- real implementation from app.py ------------------------------------------
|
| 20 |
+
src = open("app.py").read()
|
| 21 |
+
ns = {"np": np, "cv2": cv2}
|
| 22 |
+
for fn in ("def pixel_intrinsics_from_model", "def plane_homography_from_moge"):
|
| 23 |
+
start = src.index(fn)
|
| 24 |
+
end = src.index("\n\ndef ", start + 10)
|
| 25 |
+
exec(compile(src[start:end], "app.py", "exec"), ns)
|
| 26 |
+
plane_homography_from_moge = ns["plane_homography_from_moge"]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def synthetic_geometry(pitch_deg=35.0, cam_h=1.5, noise=0.0, wall=False):
|
| 30 |
+
"""Perfect metric point map of a plane seen by a pitched camera.
|
| 31 |
+
Camera frame: y down, z forward; camera pitched down by pitch_deg.
|
| 32 |
+
Floor: world plane 1.5 m below the camera. Wall: vertical plane 3 m
|
| 33 |
+
ahead (normal mostly horizontal — must trip the floor-sanity gate)."""
|
| 34 |
+
pitch = np.deg2rad(pitch_deg)
|
| 35 |
+
cp, sp = np.cos(pitch), np.sin(pitch)
|
| 36 |
+
R = np.array([[1, 0, 0], [0, cp, -sp], [0, sp, cp]]) # world -> camera
|
| 37 |
+
if wall:
|
| 38 |
+
n = R @ np.array([0.0, 0.0, -1.0])
|
| 39 |
+
c0 = R @ np.array([0.0, 0.0, 3.0])
|
| 40 |
+
else:
|
| 41 |
+
n = R @ np.array([0.0, -1.0, 0.0])
|
| 42 |
+
c0 = R @ np.array([0.0, cam_h, 0.0])
|
| 43 |
+
d = float(n @ c0)
|
| 44 |
+
|
| 45 |
+
K = np.array([[F_PX, 0, IMG_W / 2.0], [0, F_PX, IMG_H / 2.0], [0, 0, 1.0]])
|
| 46 |
+
Kinv = np.linalg.inv(K)
|
| 47 |
+
uu, vv = np.meshgrid(np.arange(IMG_W, dtype=np.float64), np.arange(IMG_H, dtype=np.float64))
|
| 48 |
+
rays = np.stack([uu, vv, np.ones_like(uu)], axis=-1) @ Kinv.T
|
| 49 |
+
denom = rays @ n
|
| 50 |
+
with np.errstate(divide="ignore", invalid="ignore"):
|
| 51 |
+
t = np.where(np.abs(denom) > 1e-9, d / denom, np.nan)
|
| 52 |
+
points = rays * t[..., None]
|
| 53 |
+
ok = np.isfinite(t) & (t > 0.5) & (t < 30.0) & (points[..., 2] > 0.05)
|
| 54 |
+
|
| 55 |
+
rng = np.random.default_rng(3)
|
| 56 |
+
if noise > 0:
|
| 57 |
+
points = points + rng.normal(0, noise, points.shape)
|
| 58 |
+
|
| 59 |
+
mask = ok & (vv > IMG_H * 0.45) # floor occupies the lower image
|
| 60 |
+
pts = points.astype(np.float32)
|
| 61 |
+
pts[~ok] = np.nan
|
| 62 |
+
K_norm = K.copy()
|
| 63 |
+
K_norm[0, 0] /= IMG_W
|
| 64 |
+
K_norm[0, 2] /= IMG_W
|
| 65 |
+
K_norm[1, 1] /= IMG_H
|
| 66 |
+
K_norm[1, 2] /= IMG_H
|
| 67 |
+
return {
|
| 68 |
+
"provider": "moge-2",
|
| 69 |
+
"points": pts,
|
| 70 |
+
"validMask": ok,
|
| 71 |
+
"intrinsics": K_norm.astype(np.float32),
|
| 72 |
+
}, mask.astype(np.uint8), points, ok
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def main():
|
| 76 |
+
ok_all = True
|
| 77 |
+
|
| 78 |
+
# 1 — recovers a metre-unit plane chart from a clean point map
|
| 79 |
+
geometry, mask, points, ok = synthetic_geometry()
|
| 80 |
+
fitted = plane_homography_from_moge(geometry, mask, IMG_W, IMG_H)
|
| 81 |
+
good = fitted is not None
|
| 82 |
+
if good:
|
| 83 |
+
H = np.asarray(fitted[0], np.float64).reshape(3, 3)
|
| 84 |
+
plane = fitted[1]
|
| 85 |
+
# measure: random floor pixel pairs, 3D distance vs plane distance
|
| 86 |
+
ys, xs = np.nonzero((mask > 0) & ok)
|
| 87 |
+
rng = np.random.default_rng(5)
|
| 88 |
+
sel = rng.choice(len(xs), 3000, replace=False)
|
| 89 |
+
i, j = sel[: len(sel) // 2], sel[len(sel) // 2 :]
|
| 90 |
+
P = points[ys, xs]
|
| 91 |
+
d3 = np.linalg.norm(P[i] - P[j], axis=1)
|
| 92 |
+
den = H[2, 0] * xs + H[2, 1] * ys + H[2, 2]
|
| 93 |
+
pa = (H[0, 0] * xs + H[0, 1] * ys + H[0, 2]) / den
|
| 94 |
+
pb = (H[1, 0] * xs + H[1, 1] * ys + H[1, 2]) / den
|
| 95 |
+
dp = np.hypot(pa[i] - pa[j], pb[i] - pb[j])
|
| 96 |
+
far = dp > 0.3
|
| 97 |
+
ratio = float(np.median(d3[far] / dp[far]))
|
| 98 |
+
good = abs(ratio - 1.0) <= 0.02 and plane.get("geometrySource") == "moge-plane"
|
| 99 |
+
print(f" [{'PASS' if good else 'FAIL'}] clean point map -> metre chart "
|
| 100 |
+
f"(3D/plane ratio {ratio:.4f}, source {plane.get('geometrySource')})")
|
| 101 |
+
else:
|
| 102 |
+
print(" [FAIL] clean point map: abstained")
|
| 103 |
+
ok_all &= good
|
| 104 |
+
|
| 105 |
+
# 2 — model intrinsics honoured: with f=612 vs the f~w=640 guess, a wrong
|
| 106 |
+
# K would skew the ratio by ~5%; the gate above (2%) already proves K is
|
| 107 |
+
# consumed, so here check the fit survives mild sensor noise
|
| 108 |
+
geometry_n, mask_n, _, _ = synthetic_geometry(noise=0.01)
|
| 109 |
+
fitted_n = plane_homography_from_moge(geometry_n, mask_n, IMG_W, IMG_H)
|
| 110 |
+
print(f" [{'PASS' if fitted_n is not None else 'FAIL'}] 1 cm point noise -> still fits")
|
| 111 |
+
ok_all &= fitted_n is not None
|
| 112 |
+
|
| 113 |
+
# 3 — wall-dominant fit must abstain (floor-normal sanity gate)
|
| 114 |
+
geometry_w, mask_w, _, _ = synthetic_geometry(wall=True)
|
| 115 |
+
fitted_w = plane_homography_from_moge(geometry_w, mask_w, IMG_W, IMG_H)
|
| 116 |
+
print(f" [{'PASS' if fitted_w is None else 'FAIL'}] wall-like plane -> abstains")
|
| 117 |
+
ok_all &= fitted_w is None
|
| 118 |
+
|
| 119 |
+
# 4 — garbage points must abstain (scale self-check / inlier gates)
|
| 120 |
+
rng = np.random.default_rng(9)
|
| 121 |
+
geometry_g, mask_g, _, _ = synthetic_geometry()
|
| 122 |
+
geometry_g["points"] = rng.uniform(0.1, 10.0, geometry_g["points"].shape).astype(np.float32)
|
| 123 |
+
fitted_g = plane_homography_from_moge(geometry_g, mask_g, IMG_W, IMG_H)
|
| 124 |
+
print(f" [{'PASS' if fitted_g is None else 'FAIL'}] random point cloud -> abstains")
|
| 125 |
+
ok_all &= fitted_g is None
|
| 126 |
+
|
| 127 |
+
# 5 — missing geometry -> None (caller falls through to the depth path)
|
| 128 |
+
none_ok = (
|
| 129 |
+
plane_homography_from_moge(None, mask, IMG_W, IMG_H) is None
|
| 130 |
+
and plane_homography_from_moge({"points": None}, mask, IMG_W, IMG_H) is None
|
| 131 |
+
)
|
| 132 |
+
print(f" [{'PASS' if none_ok else 'FAIL'}] no geometry -> None")
|
| 133 |
+
ok_all &= none_ok
|
| 134 |
+
|
| 135 |
+
print("\n" + ("ALL R1-5 SIM CHECKS PASSED" if ok_all else "R1-5 SIM CHECKS FAILED"))
|
| 136 |
+
return 0 if ok_all else 1
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
if __name__ == "__main__":
|
| 140 |
+
raise SystemExit(main())
|
visualizer.gpu.toml
CHANGED
|
@@ -9,8 +9,12 @@ mask2former_model_name = "facebook/mask2former-swin-small-ade-semantic"
|
|
| 9 |
segformer_model_name = "nvidia/segformer-b2-finetuned-ade-512-512"
|
| 10 |
depth_model_name = "depth-anything/Depth-Anything-V2-Metric-Indoor-Small-hf"
|
| 11 |
intrinsic_model_version = "v2"
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
[runtime]
|
| 14 |
enable_depth_estimation = true
|
| 15 |
enable_intrinsic_shading = true
|
|
|
|
| 16 |
data_dir = "data"
|
|
|
|
| 9 |
segformer_model_name = "nvidia/segformer-b2-finetuned-ade-512-512"
|
| 10 |
depth_model_name = "depth-anything/Depth-Anything-V2-Metric-Indoor-Small-hf"
|
| 11 |
intrinsic_model_version = "v2"
|
| 12 |
+
# R1-5 — MoGe-2 point-map geometry (CUDA-only; falls back to depth on failure)
|
| 13 |
+
geometry_model = "moge"
|
| 14 |
+
moge_model_name = "Ruicheng/moge-2-vitl-normal"
|
| 15 |
|
| 16 |
[runtime]
|
| 17 |
enable_depth_estimation = true
|
| 18 |
enable_intrinsic_shading = true
|
| 19 |
+
enable_moge_geometry = true
|
| 20 |
data_dir = "data"
|