feat(research): preserve urban geometry pipelines and qualification suites

Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:00 +03:00
parent 5d56237124
commit 69dc566665
611 changed files with 52016 additions and 28 deletions
+55 -18
View File
@@ -69,13 +69,43 @@ def unproject(pixels, depth, view, intrinsics, projection):
return (local @ np.linalg.inv(view).T)[:, :3]
def render(job, output):
def prepare_crops(jobs):
"""One source walk per bounded batch; retain source row order and numeric operations."""
from plyfile import PlyData
if not 1 <= len(jobs) <= 4 or any(j['source'] != jobs[0]['source'] for j in jobs):
raise ValueError('A crop batch requires one source and at most four windows')
source = Path('/input') / jobs[0]['source']['ply']
transform = np.asarray(jobs[0]['source']['source_to_world'], dtype=np.float64)
data = PlyData.read(source, mmap='r')['vertex'].data
rows = [[] for _ in jobs]
for start in range(0, len(data), 250000):
d = data[start:start + 250000]
xyz = np.column_stack([d[n] for n in ['x', 'y', 'z']])
world = xyz @ transform[:3, :3].T + transform[:3, 3]
for job, selected in zip(jobs, rows):
bounds = np.asarray(job['bounds_xy'], dtype=float)
mask = ((world[:, :2] >= bounds[0] - job.get('halo_m', 15)) &
(world[:, :2] <= bounds[1] + job.get('halo_m', 15))).all(axis=1)
selected.append(d[mask].copy())
for selected in rows:
result = np.concatenate(selected)
selected.clear()
yield result
def render(job, output, prepared_rows=None):
import torch
from gsplat import rasterization
from plyfile import PlyData
source = Path('/input') / job['source']['ply']
if digest(source) != job['source']['sha256']:
raise ValueError('Gaussian source checksum mismatch')
global _verified_sources
if '_verified_sources' not in globals(): _verified_sources = set()
stat = source.stat()
identity = (str(source), stat.st_size, stat.st_mtime_ns, job['source']['sha256'])
if identity not in _verified_sources:
if digest(source) != job['source']['sha256']:
raise ValueError('Gaussian source checksum mismatch')
_verified_sources.add(identity)
transform = np.asarray(job['source']['source_to_world'], dtype=np.float64)
if (transform.shape != (4, 4) or not np.isfinite(transform).all()
or not np.allclose(transform[3], [0, 0, 0, 1])
@@ -83,18 +113,21 @@ def render(job, output):
or not np.isclose(np.linalg.det(transform[:3, :3]), 1)):
raise ValueError('Only rigid source transforms are supported; bake scale into the source')
data = PlyData.read(source, mmap='r')['vertex'].data
rows = []
bounds = np.asarray(job['bounds_xy'], dtype=float)
# Chunk filtering bounds RAM while retaining every source splat in the requested tile + halo.
for start in range(0, len(data), 250000):
d = data[start:start + 250000]
xyz = np.column_stack([d[n] for n in ['x', 'y', 'z']])
world = xyz @ transform[:3, :3].T + transform[:3, 3]
mask = ((world[:, :2] >= bounds[0] - job.get('halo_m', 15)) &
(world[:, :2] <= bounds[1] + job.get('halo_m', 15))).all(axis=1)
rows.append(d[mask].copy())
d = np.concatenate(rows)
del rows
if prepared_rows is None:
rows = []
bounds = np.asarray(job['bounds_xy'], dtype=float)
# Chunk filtering bounds RAM while retaining every source splat in the requested tile + halo.
for start in range(0, len(data), 250000):
d = data[start:start + 250000]
xyz = np.column_stack([d[n] for n in ['x', 'y', 'z']])
world = xyz @ transform[:3, :3].T + transform[:3, 3]
mask = ((world[:, :2] >= bounds[0] - job.get('halo_m', 15)) &
(world[:, :2] <= bounds[1] + job.get('halo_m', 15))).all(axis=1)
rows.append(d[mask].copy())
d = np.concatenate(rows)
del rows
else:
d = prepared_rows
if not len(d):
raise ValueError('No Gaussians in the requested tile')
def tensor(names):
@@ -130,11 +163,15 @@ def infer(job, output):
import torch
from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
model_path = Path('/model')
for name, expected in job['model']['files'].items():
global _semantic_cache
if '_semantic_cache' not in globals(): _semantic_cache = None
for name, expected in (job['model']['files'].items() if _semantic_cache is None else []):
if digest(model_path / name) != expected:
raise ValueError('Model asset checksum mismatch: ' + name)
processor = AutoImageProcessor.from_pretrained(model_path, local_files_only=True)
model = Mask2FormerForUniversalSegmentation.from_pretrained(model_path, local_files_only=True).cuda().eval()
if _semantic_cache is None:
_semantic_cache = (AutoImageProcessor.from_pretrained(model_path, local_files_only=True),
Mask2FormerForUniversalSegmentation.from_pretrained(model_path, local_files_only=True).cuda().eval())
processor, model = _semantic_cache
for spec in job['views']:
if spec.get('projection', 'pinhole') != 'pinhole':
continue # Mapillary is a street-view model; orthographic views are review only.