Benjamin Auquite commited on
Commit
dfd4990
Β·
verified Β·
1 Parent(s): 51bf9f2

Deploy ImageEZGen3D

Browse files
Files changed (1) hide show
  1. app.py +133 -3
app.py CHANGED
@@ -361,7 +361,89 @@ def _fallback_notice_html(resolution: AdapterResolution) -> str:
361
  )
362
 
363
 
364
- def _hero_shell_html(title: str, resolution: AdapterResolution) -> str:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  runtime = resolution.runtime
366
  chips = [
367
  ("Runtime", runtime.requested_mode.title()),
@@ -377,6 +459,8 @@ def _hero_shell_html(title: str, resolution: AdapterResolution) -> str:
377
  else ("Armed" if resolution.selected else "Ready"),
378
  ),
379
  ]
 
 
380
  chip_html = "".join(
381
  (
382
  '<div class="hero-chip">'
@@ -539,9 +623,16 @@ def _format_report(result: dict[str, Any]) -> str:
539
  or "unknown"
540
  )
541
  adapter_label = _backend_display_label(adapter_name)
 
 
542
  lines = [
 
 
 
 
543
  f"### {result.get('stage', 'done').title()}",
544
  f"Run ID: `{result.get('run_id', 'unknown')}`",
 
545
  f"Adapter: `{adapter_label}`",
546
  f"Input score: **{validation.get('score', 'n/a')} / 100**",
547
  f"Mesh status: **{mesh.get('status', 'unchecked')}**",
@@ -781,7 +872,11 @@ def build_demo():
781
  with gr.Row(equal_height=False, elem_classes="workspace-layout"):
782
  with gr.Column(scale=8, min_width=760, elem_classes="main-column"):
783
  with gr.Group(elem_classes="workspace-panel composer-panel"):
784
- gr.HTML(_hero_shell_html(config.app.title, resolution))
 
 
 
 
785
  template_buttons: list[tuple[Any, str]] = []
786
  with gr.Row(
787
  equal_height=False, elem_classes="composer-grid"
@@ -882,6 +977,10 @@ def build_demo():
882
  value=_DEFAULT_STARTER,
883
  elem_classes="composer-control",
884
  )
 
 
 
 
885
  quality = gr.Radio(
886
  label="Quality mode",
887
  choices=["draft", "balanced", "high"],
@@ -1178,6 +1277,7 @@ def build_demo():
1178
  _mode_summary_markdown(starter_spec["key"], quality_value),
1179
  preview,
1180
  status_text,
 
1181
  )
1182
 
1183
  def apply_prompt_template(template_key, primary_image):
@@ -1196,6 +1296,7 @@ def build_demo():
1196
  _mode_summary_markdown(starter_key, quality_value),
1197
  preview,
1198
  status_text,
 
1199
  )
1200
 
1201
  def update_quality_help(quality_name, primary_image, starter_key):
@@ -1206,6 +1307,7 @@ def build_demo():
1206
  _mode_summary_markdown(starter_key, quality_name),
1207
  preview,
1208
  status_text,
 
1209
  )
1210
 
1211
  def open_history_run(history_choice):
@@ -1391,12 +1493,18 @@ def build_demo():
1391
  mode_summary,
1392
  validation_preview,
1393
  validation_status,
 
1394
  ],
1395
  )
1396
  quality.change(
1397
  update_quality_help,
1398
  inputs=[quality, primary, starter],
1399
- outputs=[mode_summary, validation_preview, validation_status],
 
 
 
 
 
1400
  )
1401
  for template_button, template_key in template_buttons:
1402
  template_button.click(
@@ -1412,6 +1520,7 @@ def build_demo():
1412
  mode_summary,
1413
  validation_preview,
1414
  validation_status,
 
1415
  ],
1416
  )
1417
 
@@ -2386,6 +2495,27 @@ _CSS = """
2386
  margin-top: 4px;
2387
  }
2388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2389
  /* ─── Fallback notice ───────────────────────────────────────────────────── */
2390
  .fallback-notice {
2391
  border-radius: 16px;
 
361
  )
362
 
363
 
364
+ def _quality_tier_label(quality_name: str | None) -> str:
365
+ if quality_name in _QUALITY_GUIDANCE:
366
+ return quality_name.title()
367
+ return "Draft"
368
+
369
+
370
+ def _quality_intake_html(quality_name: str | None = None) -> str:
371
+ selected = quality_name if quality_name in _QUALITY_GUIDANCE else "draft"
372
+ tier_items = []
373
+ for tier in ("draft", "balanced", "high"):
374
+ label = tier.title()
375
+ if tier == selected:
376
+ label = f"<strong>{escape(label)} (selected)</strong>"
377
+ else:
378
+ label = escape(label)
379
+ tier_items.append(
380
+ f"<li>{label} β€” {escape(_QUALITY_GUIDANCE[tier])}</li>"
381
+ )
382
+ return "\n".join(
383
+ [
384
+ '<section class="quality-intake">',
385
+ "<p><strong>Choose your output tier before generating.</strong></p>",
386
+ "<ul>",
387
+ *tier_items,
388
+ "</ul>",
389
+ "</section>",
390
+ ]
391
+ )
392
+
393
+
394
+ def _comprehension_exit_markdown(result: dict[str, Any]) -> str:
395
+ parameters = result.get("parameters", {})
396
+ if not isinstance(parameters, dict):
397
+ parameters = {}
398
+ quality = str(parameters.get("quality", "draft"))
399
+ quality_label = _quality_tier_label(quality)
400
+ guidance = _QUALITY_GUIDANCE.get(quality, _QUALITY_GUIDANCE["draft"])
401
+ adapter_key = str(
402
+ result.get("adapter")
403
+ or parameters.get("selected_adapter")
404
+ or parameters.get("requested_adapter")
405
+ or ""
406
+ ).lower()
407
+ adapter_label = _backend_display_label(adapter_key or "unknown")
408
+ is_preview = "cpu" in adapter_key or "demo" in adapter_key
409
+
410
+ lines = [
411
+ "## What happened",
412
+ f"- **Output tier:** {quality_label} β€” {guidance}",
413
+ f"- **Backend used:** {adapter_label}",
414
+ ]
415
+ if is_preview:
416
+ lines.append(
417
+ "- **Mesh type:** Preview geometry (CPU demo), not neural 3D reconstruction."
418
+ )
419
+ else:
420
+ lines.append("- **Mesh type:** Mesh from the selected backend path.")
421
+
422
+ if parameters.get("fallback_reason"):
423
+ lines.append(f"- **Fallback:** {parameters['fallback_reason']}")
424
+
425
+ lines.append("\n### Suggested next steps")
426
+ if is_preview:
427
+ lines.extend(
428
+ [
429
+ "- Review the capture score and normalized preview before another run.",
430
+ "- Download GLB, OBJ, and manifest when the preview looks acceptable.",
431
+ "- Switch to **balanced** or **high** after improving capture if you need more detail.",
432
+ ]
433
+ )
434
+ else:
435
+ lines.extend(
436
+ [
437
+ "- Reopen this run from **History** without losing prior artifacts.",
438
+ "- Download exports when mesh validation reports **ok**.",
439
+ ]
440
+ )
441
+ return "\n".join(lines)
442
+
443
+
444
+ def _hero_shell_html(
445
+ title: str, resolution: AdapterResolution, *, quality_name: str | None = None
446
+ ) -> str:
447
  runtime = resolution.runtime
448
  chips = [
449
  ("Runtime", runtime.requested_mode.title()),
 
459
  else ("Armed" if resolution.selected else "Ready"),
460
  ),
461
  ]
462
+ if quality_name in _QUALITY_GUIDANCE:
463
+ chips.append(("Output tier", _quality_tier_label(quality_name)))
464
  chip_html = "".join(
465
  (
466
  '<div class="hero-chip">'
 
623
  or "unknown"
624
  )
625
  adapter_label = _backend_display_label(adapter_name)
626
+ quality_name = parameters.get("quality") if isinstance(parameters, dict) else None
627
+ quality_label = _quality_tier_label(str(quality_name) if quality_name else None)
628
  lines = [
629
+ _comprehension_exit_markdown(result),
630
+ "",
631
+ "---",
632
+ "",
633
  f"### {result.get('stage', 'done').title()}",
634
  f"Run ID: `{result.get('run_id', 'unknown')}`",
635
+ f"Output tier: **{quality_label}**",
636
  f"Adapter: `{adapter_label}`",
637
  f"Input score: **{validation.get('score', 'n/a')} / 100**",
638
  f"Mesh status: **{mesh.get('status', 'unchecked')}**",
 
872
  with gr.Row(equal_height=False, elem_classes="workspace-layout"):
873
  with gr.Column(scale=8, min_width=760, elem_classes="main-column"):
874
  with gr.Group(elem_classes="workspace-panel composer-panel"):
875
+ gr.HTML(_hero_shell_html(
876
+ config.app.title,
877
+ resolution,
878
+ quality_name=config.generation.quality,
879
+ ))
880
  template_buttons: list[tuple[Any, str]] = []
881
  with gr.Row(
882
  equal_height=False, elem_classes="composer-grid"
 
977
  value=_DEFAULT_STARTER,
978
  elem_classes="composer-control",
979
  )
980
+ quality_intake_panel = gr.HTML(
981
+ _quality_intake_html(config.generation.quality),
982
+ elem_classes="quality-intake-shell",
983
+ )
984
  quality = gr.Radio(
985
  label="Quality mode",
986
  choices=["draft", "balanced", "high"],
 
1277
  _mode_summary_markdown(starter_spec["key"], quality_value),
1278
  preview,
1279
  status_text,
1280
+ _quality_intake_html(quality_value),
1281
  )
1282
 
1283
  def apply_prompt_template(template_key, primary_image):
 
1296
  _mode_summary_markdown(starter_key, quality_value),
1297
  preview,
1298
  status_text,
1299
+ _quality_intake_html(quality_value),
1300
  )
1301
 
1302
  def update_quality_help(quality_name, primary_image, starter_key):
 
1307
  _mode_summary_markdown(starter_key, quality_name),
1308
  preview,
1309
  status_text,
1310
+ _quality_intake_html(quality_name),
1311
  )
1312
 
1313
  def open_history_run(history_choice):
 
1493
  mode_summary,
1494
  validation_preview,
1495
  validation_status,
1496
+ quality_intake_panel,
1497
  ],
1498
  )
1499
  quality.change(
1500
  update_quality_help,
1501
  inputs=[quality, primary, starter],
1502
+ outputs=[
1503
+ mode_summary,
1504
+ validation_preview,
1505
+ validation_status,
1506
+ quality_intake_panel,
1507
+ ],
1508
  )
1509
  for template_button, template_key in template_buttons:
1510
  template_button.click(
 
1520
  mode_summary,
1521
  validation_preview,
1522
  validation_status,
1523
+ quality_intake_panel,
1524
  ],
1525
  )
1526
 
 
2495
  margin-top: 4px;
2496
  }
2497
 
2498
+ /* ─── Quality intake ────────────────────────────────────────────────────── */
2499
+ .quality-intake {
2500
+ border-radius: 16px;
2501
+ padding: 14px 16px;
2502
+ margin: 8px 0 10px;
2503
+ background: linear-gradient(135deg, rgba(0, 112, 243, 0.05), rgba(124, 58, 237, 0.05)) !important;
2504
+ border: 1px solid rgba(0, 112, 243, 0.14) !important;
2505
+ box-shadow: none !important;
2506
+ }
2507
+
2508
+ .quality-intake * {
2509
+ color: var(--iez-ink) !important;
2510
+ font-size: 0.86rem !important;
2511
+ line-height: 1.55 !important;
2512
+ }
2513
+
2514
+ .quality-intake ul {
2515
+ margin: 8px 0 0 1.1rem !important;
2516
+ padding: 0 !important;
2517
+ }
2518
+
2519
  /* ─── Fallback notice ───────────────────────────────────────────────────── */
2520
  .fallback-notice {
2521
  border-radius: 16px;