github-actions[bot] commited on
Commit
0f200c9
·
1 Parent(s): f0b6024

Automated Deploy: 7a921ef33d48577586757e91fecdba91d1dccce9

Browse files
config/runtime.py CHANGED
@@ -6,7 +6,7 @@ ENABLE_FLOOR_MASK_CLEANUP = config_bool("ENABLE_FLOOR_MASK_CLEANUP", "runtime",
6
  ENABLE_DEPTH_ESTIMATION = config_bool("ENABLE_DEPTH_ESTIMATION", "runtime", "enable_depth_estimation", "1")
7
  ENABLE_PLANE_FIT = config_bool("ENABLE_PLANE_FIT", "runtime", "enable_plane_fit", "1")
8
  ENABLE_MULTI_PLANE_SURFACES = config_bool("ENABLE_MULTI_PLANE_SURFACES", "runtime", "enable_multi_plane_surfaces", "1")
9
- ENABLE_WALL_SEGMENTS = config_bool("ENABLE_WALL_SEGMENTS", "runtime", "enable_wall_segments", "1")
10
  ENABLE_INTRINSIC_SHADING = config_bool("ENABLE_INTRINSIC_SHADING", "runtime", "enable_intrinsic_shading", "0")
11
  ENABLE_SHADING_TRANSFER = config_bool("ENABLE_SHADING_TRANSFER", "runtime", "enable_shading_transfer", "1")
12
  WARM_START_MODELS = config_bool("WARM_START_MODELS", "runtime", "warm_start_models", "1")
 
6
  ENABLE_DEPTH_ESTIMATION = config_bool("ENABLE_DEPTH_ESTIMATION", "runtime", "enable_depth_estimation", "1")
7
  ENABLE_PLANE_FIT = config_bool("ENABLE_PLANE_FIT", "runtime", "enable_plane_fit", "1")
8
  ENABLE_MULTI_PLANE_SURFACES = config_bool("ENABLE_MULTI_PLANE_SURFACES", "runtime", "enable_multi_plane_surfaces", "1")
9
+ ENABLE_WALL_SEGMENTS = config_bool("ENABLE_WALL_SEGMENTS", "runtime", "enable_wall_segments", "0")
10
  ENABLE_INTRINSIC_SHADING = config_bool("ENABLE_INTRINSIC_SHADING", "runtime", "enable_intrinsic_shading", "0")
11
  ENABLE_SHADING_TRANSFER = config_bool("ENABLE_SHADING_TRANSFER", "runtime", "enable_shading_transfer", "1")
12
  WARM_START_MODELS = config_bool("WARM_START_MODELS", "runtime", "warm_start_models", "1")
routes/viz2d.py CHANGED
@@ -42,12 +42,14 @@ async def convert_to_viz2d(background_tasks: BackgroundTasks, file: UploadFile =
42
  content_type = "image/jpeg"
43
  ext = ".jpg"
44
  upload_path = UPLOAD_DIR / f"{job_id}{ext}"
 
45
  upload_path.write_bytes(normalized_contents)
 
46
 
47
  size_kb = len(contents) / 1024
48
  print(
49
  f"\n[JOB {job_id[:8]}] Upload received: {original_filename} ({size_kb:.0f} KB)"
50
- f" | read={t_read:.2f}s | normalize={t_normalize:.2f}s",
51
  flush=True,
52
  )
53
 
@@ -65,6 +67,11 @@ async def convert_to_viz2d(background_tasks: BackgroundTasks, file: UploadFile =
65
  "inputUrl": f"/uploads/{upload_path.name}",
66
  "outputUrl": f"/viz2d/jobs/{job_id}/file",
67
  "debugUrl": f"/viz2d/jobs/{job_id}/debug" if DEBUG_ARTIFACTS_ENABLED else None,
 
 
 
 
 
68
  }
69
  write_job(job)
70
  background_tasks.add_task(run_conversion_task, job_id, upload_path)
 
42
  content_type = "image/jpeg"
43
  ext = ".jpg"
44
  upload_path = UPLOAD_DIR / f"{job_id}{ext}"
45
+ t0 = time.perf_counter()
46
  upload_path.write_bytes(normalized_contents)
47
+ t_persist = time.perf_counter() - t0
48
 
49
  size_kb = len(contents) / 1024
50
  print(
51
  f"\n[JOB {job_id[:8]}] Upload received: {original_filename} ({size_kb:.0f} KB)"
52
+ f" | read={t_read:.2f}s | normalize={t_normalize:.2f}s | persist={t_persist:.2f}s",
53
  flush=True,
54
  )
55
 
 
67
  "inputUrl": f"/uploads/{upload_path.name}",
68
  "outputUrl": f"/viz2d/jobs/{job_id}/file",
69
  "debugUrl": f"/viz2d/jobs/{job_id}/debug" if DEBUG_ARTIFACTS_ENABLED else None,
70
+ "requestTimings": {
71
+ "serverReadMs": round(t_read * 1000),
72
+ "normalizeMs": round(t_normalize * 1000),
73
+ "persistMs": round(t_persist * 1000),
74
+ },
75
  }
76
  write_job(job)
77
  background_tasks.add_task(run_conversion_task, job_id, upload_path)
services/jobs/conversion.py CHANGED
@@ -67,9 +67,12 @@ def run_conversion_task(job_id: str, upload_path: Path):
67
  from services.debug.capture import PipelineDebugCapture
68
  from services.pipeline.packaging import build_manifest_segmentation_bundle
69
 
 
70
  debug = PipelineDebugCapture(job_id) if DEBUG_ARTIFACTS_ENABLED else None
71
  estimate_ms = estimate_conversion_ms()
 
72
  image_bytes = upload_path.read_bytes()
 
73
  image_url = f"/uploads/{upload_path.name}"
74
 
75
  try:
@@ -117,7 +120,9 @@ def run_conversion_task(job_id: str, upload_path: Path):
117
  print(f"[JOB {job_id[:8]}] Preview failed ({preview_exc}), continuing with full pipeline.", flush=True)
118
 
119
  # ── Phase 2: Full HD pipeline ──
 
120
  with CONVERSION_GPU_LOCK:
 
121
  t_start = time.perf_counter()
122
  update_conversion_job(
123
  job_id,
@@ -128,6 +133,7 @@ def run_conversion_task(job_id: str, upload_path: Path):
128
  message="Analyzing floor (HD)\u2026",
129
  estimatedTotalMs=estimate_ms,
130
  estimatedRemainingMs=estimate_ms,
 
131
  )
132
  completed_phases: set[str] = set()
133
 
@@ -152,13 +158,37 @@ def run_conversion_task(job_id: str, upload_path: Path):
152
 
153
  bundle = build_segmentation_bundle(image_bytes, debug=debug, progress_callback=report_stage)
154
  report_stage(PipelinePhase.PACKAGING, 25)
 
155
  binary_bundle = build_manifest_segmentation_bundle(
156
  bundle, job_id, image_url=image_url, include_image=False,
157
  )
158
  (JOB_DIR / f"{job_id}.vizbundle").write_bytes(binary_bundle)
 
159
  report_stage(PipelinePhase.PACKAGING, 100)
160
  elapsed_ms = (time.perf_counter() - t_start) * 1000
161
  record_conversion_ms(elapsed_ms)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  job = read_job(job_id)
163
  job["status"] = JobStatus.COMPLETED
164
  job["phase"] = "completed"
@@ -170,7 +200,11 @@ def run_conversion_task(job_id: str, upload_path: Path):
170
  job["durationMs"] = round(elapsed_ms)
171
  job["modelName"] = bundle.get("modelName")
172
  job["models"] = bundle.get("models")
173
- job["pipelineStages"] = bundle.get("pipelineStages")
 
 
 
 
174
  job["outputFormat"] = "split-vizbundle"
175
  write_job(job)
176
  print(f"\n[JOB {job_id[:8]}] HD conversion completed in {elapsed_ms / 1000:.2f}s\n", flush=True)
 
67
  from services.debug.capture import PipelineDebugCapture
68
  from services.pipeline.packaging import build_manifest_segmentation_bundle
69
 
70
+ task_started = time.perf_counter()
71
  debug = PipelineDebugCapture(job_id) if DEBUG_ARTIFACTS_ENABLED else None
72
  estimate_ms = estimate_conversion_ms()
73
+ t_read = time.perf_counter()
74
  image_bytes = upload_path.read_bytes()
75
+ input_read_ms = (time.perf_counter() - t_read) * 1000
76
  image_url = f"/uploads/{upload_path.name}"
77
 
78
  try:
 
120
  print(f"[JOB {job_id[:8]}] Preview failed ({preview_exc}), continuing with full pipeline.", flush=True)
121
 
122
  # ── Phase 2: Full HD pipeline ──
123
+ gpu_wait_started = time.perf_counter()
124
  with CONVERSION_GPU_LOCK:
125
+ gpu_queue_wait_ms = (time.perf_counter() - gpu_wait_started) * 1000
126
  t_start = time.perf_counter()
127
  update_conversion_job(
128
  job_id,
 
133
  message="Analyzing floor (HD)\u2026",
134
  estimatedTotalMs=estimate_ms,
135
  estimatedRemainingMs=estimate_ms,
136
+ gpuQueueWaitMs=round(gpu_queue_wait_ms),
137
  )
138
  completed_phases: set[str] = set()
139
 
 
158
 
159
  bundle = build_segmentation_bundle(image_bytes, debug=debug, progress_callback=report_stage)
160
  report_stage(PipelinePhase.PACKAGING, 25)
161
+ serialization_started = time.perf_counter()
162
  binary_bundle = build_manifest_segmentation_bundle(
163
  bundle, job_id, image_url=image_url, include_image=False,
164
  )
165
  (JOB_DIR / f"{job_id}.vizbundle").write_bytes(binary_bundle)
166
+ serialization_ms = (time.perf_counter() - serialization_started) * 1000
167
  report_stage(PipelinePhase.PACKAGING, 100)
168
  elapsed_ms = (time.perf_counter() - t_start) * 1000
169
  record_conversion_ms(elapsed_ms)
170
+ pipeline_stages = [
171
+ stage for stage in (bundle.get("pipelineStages") or [])
172
+ if stage.get("name") != "TOTAL"
173
+ ]
174
+ pipeline_stages.append({
175
+ "name": "Bundle Serialization",
176
+ "elapsed_s": round(serialization_ms / 1000, 3),
177
+ "detail": f"{len(binary_bundle) / 1024:.0f} KB",
178
+ })
179
+ accounted_s = sum(float(stage.get("elapsed_s") or 0.0) for stage in pipeline_stages)
180
+ conversion_overhead_s = max(0.0, elapsed_ms / 1000 - accounted_s)
181
+ if conversion_overhead_s >= 0.001:
182
+ pipeline_stages.append({
183
+ "name": "Conversion Overhead",
184
+ "elapsed_s": round(conversion_overhead_s, 3),
185
+ "detail": "job-state updates and orchestration",
186
+ })
187
+ pipeline_stages.append({
188
+ "name": "TOTAL",
189
+ "elapsed_s": round(elapsed_ms / 1000, 3),
190
+ "detail": "full HD conversion",
191
+ })
192
  job = read_job(job_id)
193
  job["status"] = JobStatus.COMPLETED
194
  job["phase"] = "completed"
 
200
  job["durationMs"] = round(elapsed_ms)
201
  job["modelName"] = bundle.get("modelName")
202
  job["models"] = bundle.get("models")
203
+ job["pipelineStages"] = pipeline_stages
204
+ job["inputReadMs"] = round(input_read_ms)
205
+ job["gpuQueueWaitMs"] = round(gpu_queue_wait_ms)
206
+ job["bundleSerializationMs"] = round(serialization_ms)
207
+ job["taskDurationMs"] = round((time.perf_counter() - task_started) * 1000)
208
  job["outputFormat"] = "split-vizbundle"
209
  write_job(job)
210
  print(f"\n[JOB {job_id[:8]}] HD conversion completed in {elapsed_ms / 1000:.2f}s\n", flush=True)
services/pipeline/builder.py CHANGED
@@ -191,9 +191,17 @@ def build_segmentation_bundle(contents: bytes, debug: PipelineDebugCapture | Non
191
  if d:
192
  debug_stages.record_lighting(d, shade_map, showroom_shade_map, reflection_map, surface_mask, lighting_source, el)
193
 
 
 
194
  wall_mask = seg_class_mask(seg_map, class_ids({"wall"}))
195
- wall_components, wall_protected_mask = (
196
- wall_surface_components(seg_map, min_floor_area, geometry) if ENABLE_WALL_SEGMENTS else ([], np.zeros_like(wall_mask)))
 
 
 
 
 
 
197
 
198
  # --- Pre-compute wall lighting in parallel with floor direction ---
199
  # Wall lighting was previously computed inside build_wall_segment (in the
@@ -242,9 +250,11 @@ def build_segmentation_bundle(contents: bytes, debug: PipelineDebugCapture | Non
242
  # Collect pre-computed wall lighting results
243
  wall_lighting_results: list[dict | None] = []
244
  if wall_executor:
 
245
  for fut in wall_lighting_futures:
246
  wall_lighting_results.append(fut.result())
247
  wall_executor.shutdown(wait=False)
 
248
  else:
249
  wall_lighting_results = [None] * len(wall_components)
250
 
@@ -279,15 +289,26 @@ def build_segmentation_bundle(contents: bytes, debug: PipelineDebugCapture | Non
279
  if progress_callback:
280
  progress_callback(PipelinePhase.PACKAGING, 100)
281
  _log_stage("Packaging", t0, f"segments={len(segments)}")
 
 
 
 
 
282
  total_elapsed = time.perf_counter() - t_start
 
 
 
 
 
 
 
 
283
 
284
  # ── Print clean timing summary ──
285
  _print_pipeline_summary(stage_times, total_elapsed, w, h)
286
 
287
  if d:
288
  d.complete(total_elapsed * 1000)
289
- pixels_b64 = _pixels_b64_future.result()
290
- _img_pool.shutdown(wait=False)
291
  pipeline_stages = [
292
  {"name": name, "elapsed_s": round(elapsed, 3), "detail": detail}
293
  for name, elapsed, detail in stage_times
 
191
  if d:
192
  debug_stages.record_lighting(d, shade_map, showroom_shade_map, reflection_map, surface_mask, lighting_source, el)
193
 
194
+ # The semantic wall mask remains useful as a structural cue for floor
195
+ # direction, even when wall surfaces are not emitted in the bundle.
196
  wall_mask = seg_class_mask(seg_map, class_ids({"wall"}))
197
+ wall_components = []
198
+ wall_protected_mask = None
199
+ if ENABLE_WALL_SEGMENTS:
200
+ t0 = time.perf_counter()
201
+ wall_components, wall_protected_mask = wall_surface_components(
202
+ seg_map, min_floor_area, geometry,
203
+ )
204
+ _log_stage("Wall Discovery", t0, f"components={len(wall_components)}")
205
 
206
  # --- Pre-compute wall lighting in parallel with floor direction ---
207
  # Wall lighting was previously computed inside build_wall_segment (in the
 
250
  # Collect pre-computed wall lighting results
251
  wall_lighting_results: list[dict | None] = []
252
  if wall_executor:
253
+ t0 = time.perf_counter()
254
  for fut in wall_lighting_futures:
255
  wall_lighting_results.append(fut.result())
256
  wall_executor.shutdown(wait=False)
257
+ _log_stage("Wall Lighting Wait", t0, f"components={len(wall_components)}")
258
  else:
259
  wall_lighting_results = [None] * len(wall_components)
260
 
 
289
  if progress_callback:
290
  progress_callback(PipelinePhase.PACKAGING, 100)
291
  _log_stage("Packaging", t0, f"segments={len(segments)}")
292
+ t0 = time.perf_counter()
293
+ pixels_b64 = _pixels_b64_future.result()
294
+ _img_pool.shutdown(wait=False)
295
+ _log_stage("Image Encoding Wait", t0)
296
+
297
  total_elapsed = time.perf_counter() - t_start
298
+ accounted_elapsed = sum(elapsed for _, elapsed, _ in stage_times)
299
+ overhead_elapsed = max(0.0, total_elapsed - accounted_elapsed)
300
+ if overhead_elapsed >= 0.001:
301
+ stage_times.append((
302
+ "Pipeline Overhead",
303
+ overhead_elapsed,
304
+ "callbacks, metadata and untimed glue",
305
+ ))
306
 
307
  # ── Print clean timing summary ──
308
  _print_pipeline_summary(stage_times, total_elapsed, w, h)
309
 
310
  if d:
311
  d.complete(total_elapsed * 1000)
 
 
312
  pipeline_stages = [
313
  {"name": name, "elapsed_s": round(elapsed, 3), "detail": detail}
314
  for name, elapsed, detail in stage_times
visualizer.gpu.toml CHANGED
@@ -17,7 +17,7 @@ enable_depth_estimation = true
17
  enable_moge_geometry = true
18
  enable_plane_fit = true
19
  enable_multi_plane_surfaces = true
20
- enable_wall_segments = true
21
  enable_intrinsic_shading = false
22
  enable_shading_transfer = false
23
  enable_sam_refinement = false
 
17
  enable_moge_geometry = true
18
  enable_plane_fit = true
19
  enable_multi_plane_surfaces = true
20
+ enable_wall_segments = false
21
  enable_intrinsic_shading = false
22
  enable_shading_transfer = false
23
  enable_sam_refinement = false
visualizer.hf.toml CHANGED
@@ -17,7 +17,7 @@ enable_depth_estimation = true
17
  enable_moge_geometry = true
18
  enable_plane_fit = true
19
  enable_multi_plane_surfaces = true
20
- enable_wall_segments = true
21
  enable_intrinsic_shading = false
22
  enable_shading_transfer = false
23
  enable_sam_refinement = false
 
17
  enable_moge_geometry = true
18
  enable_plane_fit = true
19
  enable_multi_plane_surfaces = true
20
+ enable_wall_segments = false
21
  enable_intrinsic_shading = false
22
  enable_shading_transfer = false
23
  enable_sam_refinement = false
visualizer.local.toml CHANGED
@@ -13,7 +13,7 @@ sam2_checkpoint = ""
13
  enable_depth_estimation = false
14
  enable_plane_fit = true
15
  enable_multi_plane_surfaces = true
16
- enable_wall_segments = true
17
  enable_intrinsic_shading = false
18
  enable_shading_transfer = true
19
  enable_sam_refinement = false
 
13
  enable_depth_estimation = false
14
  enable_plane_fit = true
15
  enable_multi_plane_surfaces = true
16
+ enable_wall_segments = false
17
  enable_intrinsic_shading = false
18
  enable_shading_transfer = true
19
  enable_sam_refinement = false