Spaces:
Sleeping
Sleeping
Download app.py from jackmowden/ImageEZGen3D: direct link, hf CLI and curl.
- Browser
- Download file 135 kB
-
https://huggingface.co/spaces/jackmowden/ImageEZGen3D/resolve/main/app.py
- Command line
-
hf download hf://spaces/jackmowden/ImageEZGen3D/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jackmowden/ImageEZGen3D/resolve/main/app.py
135 kB
from __future__ import annotations
import sys
import tempfile
from html import escape
from pathlib import Path
from typing import Any, cast
_SRC_DIR = Path(__file__).resolve().parent / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
GRADIO_IMPORT_ERROR: Exception | None = None
try:
import gradio as gr
except Exception as exc: # pragma: no cover - exercised only when app deps missing
gr = None # type: ignore[assignment]
GRADIO_IMPORT_ERROR = exc
else:
GRADIO_IMPORT_ERROR = None
from imageezgen3d.config import load_config # noqa: E402
from imageezgen3d.exporters import make_box_mesh, write_glb # noqa: E402
from imageezgen3d import manifest_ui as _manifest_ui # noqa: E402
from imageezgen3d.orchestrator import ( # noqa: E402
AdapterResolution,
ImageEZOrchestrator,
)
from imageezgen3d.jobs import JobService # noqa: E402
from imageezgen3d.jobs.gradio_bridge import ( # noqa: E402
build_animate_job_request,
build_job_request_from_gradio,
build_mesh_op_job_request,
build_retexture_job_request,
capture_retry_snapshot,
resolve_generation_input_modality,
run_via_job_queue,
)
from imageezgen3d.preprocess import normalize_image, validate_image # noqa: E402
from imageezgen3d.runtime import running_on_hugging_face_space # noqa: E402
from imageezgen3d.gradio_artifact_layout import ( # noqa: E402
UI_ARTIFACT_LABELS,
artifact_download_values,
resolve_artifact_row_layout,
resolve_gradio_download_keys,
session_artifact_values,
sync_session_artifact_keys,
)
from imageezgen3d.storage import RunStore # noqa: E402
from imageezgen3d import workspace_ui as _workspace_ui # noqa: E402
_EXAMPLE_SPECS = (
{
"filename": "teal_block.png",
"color": (31, 147, 139),
"label": "Block",
"pack": "shape-basics",
"shape": "block",
},
{
"filename": "red_vase.png",
"color": (191, 57, 72),
"label": "Vase",
"pack": "shape-basics",
"shape": "vase",
},
{
"filename": "cobalt_canister.png",
"color": (53, 91, 196),
"label": "Canister",
"pack": "product-focus",
"shape": "canister",
},
{
"filename": "amber_bottle.png",
"color": (196, 127, 44),
"label": "Bottle",
"pack": "product-focus",
"shape": "bottle",
},
{
"filename": "mint_figurine.png",
"color": (85, 168, 131),
"label": "Figurine",
"pack": "character-forms",
"shape": "figurine",
},
{
"filename": "stone_bust.png",
"color": (122, 126, 139),
"label": "Bust",
"pack": "character-forms",
"shape": "bust",
},
)
_STARTER_FLOWS = (
{
"key": "single-photo-draft",
"label": "Single Photo Draft",
"quality": "draft",
"summary": "Fast first pass from one clear hero image.",
"capture": "Use one centered photo with a clean silhouette and minimal occlusion.",
"brief": "Single object reconstruction from one primary image. Keep the silhouette faithful and prioritize a fast draft mesh.",
},
{
"key": "clean-product-turntable",
"label": "Clean Product Turntable",
"quality": "balanced",
"summary": "Product-style capture for centered objects and export review.",
"capture": "Use a plain background, leave margin around the object, and avoid harsh cast shadows.",
"brief": "Centered product capture. Preserve symmetry, keep the base grounded, and produce export-ready GLB and OBJ files.",
},
{
"key": "stylized-figurine",
"label": "Stylized Figurine",
"quality": "balanced",
"summary": "Toy-like or collectible interpretation from a strong front view.",
"capture": "Prefer a front three-quarter view with bright lighting and a readable outline.",
"brief": "Stylized figurine pass. Preserve the character read first, then refine depth and volume for a display-friendly mesh.",
},
{
"key": "museum-bust",
"label": "Museum Bust",
"quality": "balanced",
"summary": "Face-forward object or bust capture with conservative shaping.",
"capture": "Use a frontal image with even lighting and keep facial or carved details unobstructed.",
"brief": "Bust-oriented reconstruction. Preserve the front read and overall proportions while avoiding exaggerated depth.",
},
{
"key": "multi-view-quality",
"label": "Multi-View Quality",
"quality": "high",
"summary": "Best available quality path when you can supply labeled side views.",
"capture": "Add front, back, left, and right views when possible and keep scale consistent between shots.",
"brief": "Multi-view quality pass. Use all labeled views to improve depth, produce cleaner exports, and document the run for later comparison.",
},
)
_STARTER_FLOW_BY_KEY = {item["key"]: item for item in _STARTER_FLOWS}
_DEFAULT_STARTER = _STARTER_FLOWS[0]["key"]
_QUALITY_GUIDANCE = {
"draft": "Quick preview for first-pass structure, fallbacks, and capture validation.",
"balanced": "Middle path for cleaner proportions and more dependable multi-view blending.",
"high": "Best available detail path. Prefer this when capture quality is strong or multiple views are available.",
}
_HISTORY_LIMIT = 12
_MODEL_CLEAR_COLOR = (0.96, 0.97, 0.98, 1.0)
_SAMPLE_PACK_SPECS = (
{
"key": "shape-basics",
"label": "Shape Basics",
"note": "Repo-local starter captures for quick silhouette checks and smoke-test runs.",
},
{
"key": "product-focus",
"label": "Product Focus",
"note": "Centered product-style captures for turntable prompts and export review.",
},
{
"key": "character-forms",
"label": "Character Forms",
"note": "Bust and figurine captures tuned for stylized or face-forward reconstructions.",
},
)
_PROMPT_TEMPLATES = (
{
"key": "fast-silhouette",
"title": "Fast Silhouette",
"summary": "Quick first-pass mesh from one clean hero frame.",
"starter": "single-photo-draft",
"quality": "draft",
"brief": "Single object reconstruction from one clear primary image. Preserve the silhouette first, keep the mesh lightweight, and optimize for a fast preview pass.",
"badge": "Draft",
},
{
"key": "studio-product",
"title": "Studio Product",
"summary": "Centered product hero shot with grounded base and clean margins.",
"starter": "clean-product-turntable",
"quality": "balanced",
"brief": "Centered product capture with soft negative space, stable footing, and a clean silhouette. Preserve symmetry, keep the object grounded, and produce export-ready GLB and OBJ files.",
"badge": "Image",
},
{
"key": "collectible-pose",
"title": "Collectible Pose",
"summary": "Toy-like or character-led reconstruction from a readable front angle.",
"starter": "stylized-figurine",
"quality": "balanced",
"brief": "Stylized figurine pass from a readable front three-quarter image. Protect the character read, keep the pose legible, and refine depth without losing the silhouette.",
"badge": "Figurine",
},
{
"key": "museum-study",
"title": "Museum Study",
"summary": "Conservative bust-oriented shaping with even lighting cues.",
"starter": "museum-bust",
"quality": "balanced",
"brief": "Bust-oriented reconstruction with even lighting and stable front-facing proportions. Preserve the front read, avoid exaggerated depth, and keep facial or carved details coherent.",
"badge": "Bust",
},
{
"key": "multi-view-review",
"title": "Multi-View Review",
"summary": "High-quality pass when front, back, and side views are available.",
"starter": "multi-view-quality",
"quality": "high",
"brief": "Multi-view quality pass using all labeled captures. Improve depth consistency, produce cleaner exports, and store enough run context for later side-by-side review.",
"badge": "High",
},
)
_PROMPT_TEMPLATE_BY_KEY = {item["key"]: item for item in _PROMPT_TEMPLATES}
_TEXT_PROMPT_TEMPLATES = (
{
"key": "text-prop",
"title": "Simple prop",
"prompt": "A small wooden treasure chest with metal hinges and a rounded lid.",
"lane": "draft",
},
{
"key": "text-character",
"title": "Character bust",
"prompt": "Stylized fantasy character bust with braided hair and a calm expression.",
"lane": "production",
},
{
"key": "text-product",
"title": "Product bottle",
"prompt": "Sleek cosmetic bottle with a matte ceramic body and a narrow neck.",
"lane": "production",
},
)
_LANE_GUIDANCE = {
"draft": "Fast preview lane for first-pass geometry and workflow validation.",
"production": "Higher-fidelity lane with more decimation budget when adapters support it.",
"preview": "Meshy-style preview pass β lightweight GLB/OBJ geometry without PBR maps.",
"refine": "Meshy-style refine pass β full exports with reference texture and PBR maps.",
}
def _example_path(spec: dict[str, Any]) -> Path:
return Path("assets/examples") / str(spec["filename"])
def _accent_color(color: tuple[int, int, int]) -> tuple[int, int, int, int]:
boosted = tuple(min(255, component + 28) for component in color)
return boosted[0], boosted[1], boosted[2], 255
def _render_example_image(path: Path, spec: dict[str, Any]) -> None:
from PIL import Image, ImageDraw
color = cast(tuple[int, int, int], spec["color"])
accent = _accent_color(color)
image = Image.new("RGBA", (640, 640), (245, 247, 250, 255))
draw = ImageDraw.Draw(image)
draw.rounded_rectangle(
(96, 88, 544, 552),
radius=54,
outline=(225, 229, 236, 255),
width=4,
)
shape = str(spec["shape"])
if shape == "block":
draw.rounded_rectangle((174, 152, 466, 488), radius=36, fill=color + (255,))
draw.ellipse((232, 110, 408, 188), fill=accent)
elif shape == "vase":
draw.ellipse((248, 126, 392, 182), fill=accent)
draw.polygon(
[(272, 170), (368, 170), (430, 448), (210, 448)],
fill=color + (255,),
)
draw.rounded_rectangle((218, 432, 422, 494), radius=30, fill=accent)
elif shape == "canister":
draw.rounded_rectangle((214, 128, 426, 492), radius=62, fill=color + (255,))
draw.rounded_rectangle((244, 108, 396, 162), radius=24, fill=accent)
draw.rounded_rectangle(
(244, 238, 396, 308), radius=18, fill=(255, 255, 255, 132)
)
elif shape == "bottle":
draw.rounded_rectangle((286, 132, 354, 220), radius=24, fill=accent)
draw.rounded_rectangle((236, 210, 404, 498), radius=70, fill=color + (255,))
draw.ellipse((244, 256, 396, 356), fill=(255, 255, 255, 120))
elif shape == "figurine":
draw.ellipse((256, 110, 384, 238), fill=accent)
draw.rounded_rectangle((236, 226, 404, 430), radius=46, fill=color + (255,))
draw.rounded_rectangle((252, 420, 304, 500), radius=22, fill=color + (255,))
draw.rounded_rectangle((336, 420, 388, 500), radius=22, fill=color + (255,))
draw.rounded_rectangle((214, 270, 248, 396), radius=16, fill=accent)
draw.rounded_rectangle((392, 270, 426, 396), radius=16, fill=accent)
elif shape == "bust":
draw.ellipse((246, 110, 394, 250), fill=accent)
draw.rounded_rectangle((226, 232, 414, 432), radius=56, fill=color + (255,))
draw.rounded_rectangle((194, 430, 446, 498), radius=24, fill=accent)
else:
draw.rounded_rectangle((190, 150, 450, 490), radius=42, fill=color + (255,))
draw.text((230, 566), str(spec["label"]), fill=(31, 41, 55, 255))
image.save(path)
def _ensure_examples() -> list[list[str]]:
examples_dir = Path("assets/examples")
examples_dir.mkdir(parents=True, exist_ok=True)
examples: list[list[str]] = []
for spec in _EXAMPLE_SPECS:
path = _example_path(spec)
if not path.exists():
_render_example_image(path, spec)
examples.append([str(path)])
return examples
def _repo_sample_packs() -> list[dict[str, Any]]:
_ensure_examples()
packs: list[dict[str, Any]] = []
for pack in _SAMPLE_PACK_SPECS:
pack_examples: list[list[str]] = []
pack_labels: list[str] = []
for spec in _EXAMPLE_SPECS:
if spec["pack"] != pack["key"]:
continue
pack_examples.append([str(_example_path(spec))])
pack_labels.append(str(spec["label"]))
packs.append(
{
"key": pack["key"],
"label": pack["label"],
"note": pack["note"],
"examples": pack_examples,
"example_labels": pack_labels,
"count": len(pack_examples),
}
)
return packs
def _sample_packs_note(packs: list[dict[str, Any]]) -> str:
if not packs:
return "Repo-local sample packs will appear here once starter captures are available."
counts = [f"**{pack['label']}** ({pack['count']})" for pack in packs]
return (
"Repo-local sample packs: "
+ " Β· ".join(counts)
+ ". These samples ship with this repository so local and hosted runs keep the same starter library."
)
def _surface_header_html(eyebrow: str, title: str, body: str) -> str:
return "\n".join(
[
'<div class="surface-header-copy">',
f'<p class="surface-eyebrow">{escape(eyebrow)}</p>',
f"<h2>{escape(title)}</h2>",
f'<p class="surface-copy">{escape(body)}</p>',
"</div>",
]
)
def _backend_display_label(value: object) -> str:
raw_value = str(value or "").strip()
normalized = raw_value.lower().replace("_", "-")
if not raw_value:
return "Unknown backend"
if normalized == "auto":
return "Auto"
if normalized == "pending":
return "Pending"
if normalized == "unavailable":
return "Unavailable"
if "zerogpu" in normalized:
return "Hosted ZeroGPU"
if "gpu" in normalized:
return "Local GPU"
if "cpu" in normalized:
return "Local CPU Preview"
if "demo" in normalized:
return "Preview backend"
return raw_value.replace("-", " ").replace("_", " ").title()
def _is_preview_fallback(resolution: AdapterResolution) -> bool:
return _manifest_ui.is_preview_fallback(
{
"selected_adapter": resolution.selected,
"fallback_reason": resolution.fallback_reason,
}
)
def _fallback_notice_html(resolution: AdapterResolution) -> str:
return _manifest_ui.fallback_banner_html(
{
"selected_adapter": resolution.selected,
"fallback_reason": resolution.fallback_reason,
"runtime_message": resolution.message,
}
)
def _quality_tier_label(quality_name: str | None) -> str:
return _manifest_ui.quality_tier_label(quality_name)
def _quality_intake_html(quality_name: str | None = None) -> str:
selected = quality_name if quality_name in _QUALITY_GUIDANCE else "draft"
tier_items = []
for tier in ("draft", "balanced", "high"):
label = tier.title()
if tier == selected:
label = f"<strong>{escape(label)} (selected)</strong>"
else:
label = escape(label)
tier_items.append(
f"<li>{label} β {escape(_QUALITY_GUIDANCE[tier])}</li>"
)
return "\n".join(
[
'<section class="quality-intake">',
"<p><strong>Choose your output tier before generating.</strong></p>",
"<ul>",
*tier_items,
"</ul>",
"</section>",
]
)
def _comprehension_exit_markdown(result: dict[str, Any]) -> str:
return _manifest_ui.comprehension_exit_markdown(result)
def _credit_preview_html(
input_modality_name: str | None,
generation_lane_name: str | None,
*,
quality_name: str | None = None,
) -> str:
return _workspace_ui.credit_footer_html(
{
"input_modality": input_modality_name or "image",
"lane": generation_lane_name or "draft",
"enable_pbr": (generation_lane_name or "draft") == "refine",
"quality": quality_name,
}
)
def _mesh_inspect_parameters(payload: dict[str, Any]) -> dict[str, Any]:
parameters = payload.get("parameters", {})
if not isinstance(parameters, dict):
parameters = {}
mesh_report = payload.get("mesh_report")
if isinstance(mesh_report, dict):
merged_parameters = dict(parameters)
merged_parameters.setdefault("mesh_report", mesh_report)
return merged_parameters
return parameters
def _preview_mesh_extras_html(payload: dict[str, Any]) -> str:
artifacts = payload.get("artifacts", {})
if not isinstance(artifacts, dict):
artifacts = {}
parts = [
_workspace_ui.mesh_stats_card_html(_mesh_inspect_parameters(payload)),
_workspace_ui.pbr_channel_strip_html(artifacts),
]
return "\n".join(part for part in parts if part)
def _run_inspect_extras_html(payload: dict[str, Any]) -> str:
artifacts = payload.get("artifacts", {})
if not isinstance(artifacts, dict):
artifacts = {}
parts = [
_workspace_ui.mesh_stats_card_html(_mesh_inspect_parameters(payload)),
_workspace_ui.pbr_channel_strip_html(artifacts),
]
stub_bar = _workspace_ui.viewer_action_stub_bar_html()
parts.append(
stub_bar if stub_bar else _workspace_ui.viewer_action_bar_html()
)
return "\n".join(part for part in parts if part)
def _history_inspect_html(payload: dict[str, Any], missing_keys: list[str]) -> str:
card = _manifest_ui.run_status_card_html(payload)
artifacts = payload.get("artifacts", {})
if not isinstance(artifacts, dict):
artifacts = {}
strip = _manifest_ui.artifact_strip_html(artifacts, missing=missing_keys)
extras = _run_inspect_extras_html(payload)
return "\n".join(part for part in (card, strip, extras) if part)
def _meshy_lane_panel_html(lane_key: str) -> str:
copy = {
"image": (
"Image lane",
"2D generation and retexture",
"Use text-to-image and image-to-image demo adapters through the job API; "
"retexture jobs accept an existing mesh plus a style prompt.",
),
"print": (
"Print lane",
"Printability analyze, repair, and multi-color 3MF",
"Analyze printability is free in the Meshy pricing table; repair and multi-color "
"3MF export cost 10 credits each and map to mesh_ops printability and "
"multi_color_print helpers.",
),
"animate": (
"Animate lane",
"Auto-rig and animation library",
"Rigging and animation demo adapters expose Meshy-shaped task types; pick a catalog "
"animation such as Walking_man when submitting animate jobs.",
),
}
title, eyebrow, body = copy[lane_key]
return "\n".join(
[
'<section class="meshy-lane-panel">',
f'<p class="surface-eyebrow">{escape(eyebrow)}</p>',
f"<h2>{escape(title)}</h2>",
f'<p class="meshy-lane-copy">{escape(body)}</p>',
"</section>",
]
)
def _hero_shell_html(
title: str, resolution: AdapterResolution, *, quality_name: str | None = None
) -> str:
runtime = resolution.runtime
chips = [
("Runtime", runtime.requested_mode.title()),
(
"Default backend",
_backend_display_label(resolution.selected or "Pending"),
),
("ZeroGPU live", "Yes" if runtime.zerogpu_runtime_available else "No"),
(
"Fallback",
"Active"
if resolution.fallback_reason
else ("Armed" if resolution.selected else "Ready"),
),
]
if quality_name in _QUALITY_GUIDANCE:
chips.append(("Output tier", _quality_tier_label(quality_name)))
chip_html = "".join(
(
'<div class="hero-chip">'
f'<span class="hero-chip-label">{escape(label)}</span>'
f'<span class="hero-chip-value">{escape(value)}</span>'
"</div>"
)
for label, value in chips
)
return "\n".join(
[
'<section class="hero-shell">',
'<div class="hero-copy">',
'<p class="surface-eyebrow">Model</p>',
f"<h1>{escape(title)}</h1>",
(
'<p class="hero-copy-text">'
"One image, one brief \u2014 generate a 3D mesh in seconds."
"</p>"
),
f'<div class="hero-chip-row">{chip_html}</div>',
"</div>",
"</section>",
]
)
def _sample_pack_header_html(pack: dict[str, Any]) -> str:
return "\n".join(
[
'<div class="sample-pack-head">',
f'<span class="sample-pack-count">{escape(str(pack["count"]))} shots</span>',
f"<h3>{escape(str(pack['label']))}</h3>",
f"<p>{escape(str(pack['note']))}</p>",
"</div>",
]
)
def _prompt_template_card_html(template: dict[str, Any]) -> str:
starter = _STARTER_FLOW_BY_KEY[str(template["starter"])]
tone = str(template["key"]).replace("_", "-")
return "\n".join(
[
f'<div class="template-card-copy template-tone-{escape(tone)}">',
'<div class="template-card-top">',
f'<span class="template-card-badge">{escape(str(template["badge"]))}</span>',
f'<span class="template-card-quality">{escape(str(template["quality"]).title())}</span>',
"</div>",
f"<h3>{escape(str(template['title']))}</h3>",
f'<p class="template-card-summary">{escape(str(template["summary"]))}</p>',
'<div class="template-card-meta">',
f"<span>{escape(starter['label'])}</span>",
f"<span>{escape(_summarize_text(template['brief'], 120))}</span>",
"</div>",
"</div>",
]
)
def _history_overview_html(
items: list[dict[str, Any]],
*,
resolution: AdapterResolution | None = None,
) -> str:
latest = items[0] if items else {}
latest_run = str(latest.get("run_id", "No runs yet"))
latest_backend = _backend_display_label(
latest.get("adapter", "Generate a first preview")
)
latest_flow = str(latest.get("starter_flow") or "Starter flow pending")
fallback_count = sum(1 for item in items if item.get("fallback_reason"))
if items:
backend_chips = _manifest_ui.backend_rail_chips_html(
adapter_key=str(latest.get("adapter") or "unknown"),
fallback_reason=latest.get("fallback_reason"),
)
elif resolution is not None:
backend_chips = _manifest_ui.backend_rail_chips_html(
adapter_key=resolution.selected,
fallback_reason=resolution.fallback_reason,
)
else:
backend_chips = ""
cards = [
("Local runs", str(len(items))),
("Fallbacks logged", str(fallback_count)),
("Latest backend", latest_backend),
]
card_html = "".join(
(
'<div class="history-stat-card">'
f'<span class="history-stat-label">{escape(label)}</span>'
f"<strong>{escape(value)}</strong>"
"</div>"
)
for label, value in cards
)
return "\n".join(
[
'<section class="history-overview">',
'<div class="history-overview-copy">',
'<p class="surface-eyebrow">Project Rail</p>',
"<h2>Reopen local runs in context</h2>",
(
'<p class="surface-copy">'
+ (
"Generate a first preview to populate recent runs, starter flow context, and export recovery."
if not items
else f"Latest run <strong>{escape(latest_run)}</strong> keeps its starter flow, backend choice, and exported bundle attached."
)
+ "</p>"
),
f'<p class="history-overview-latest">{escape(latest_flow)}</p>',
"</div>",
f'<div class="history-stat-grid">{card_html}</div>',
backend_chips,
"</section>",
]
)
def _ensure_placeholder_model() -> str:
path = Path("assets/examples/placeholder.glb")
if not path.exists():
path.parent.mkdir(parents=True, exist_ok=True)
mesh = make_box_mesh(1.0, 0.74, 1.35, (0.12, 0.58, 0.55, 1.0))
write_glb(mesh, path)
return str(path)
def _verified_artifact_state(
store: RunStore, artifacts: dict[str, Any] | None
) -> tuple[dict[str, str], list[str]]:
if not isinstance(artifacts, dict):
return {}, []
verified: dict[str, str] = {}
missing: list[str] = []
for key, value in artifacts.items():
if value in (None, ""):
continue
resolved_value = store.artifact_value(value)
if resolved_value is None:
missing.append(str(key))
continue
verified[str(key)] = resolved_value
return verified, missing
def _generation_pending_report() -> str:
return "Generation in progress. Preview and downloads will appear after verified output files are written."
def _stale_artifact_report(run_id: str, missing_keys: list[str]) -> str:
missing_list = ", ".join(f"`{item}`" for item in missing_keys)
return (
"### Recovery Needed\n"
f"Run ID: `{run_id}`\n"
"The selected run references files that are no longer available. "
f"Missing artifacts: {missing_list}."
)
def _format_report(result: dict[str, Any]) -> str:
return _manifest_ui.format_run_report_markdown(result)
def _error_report(message: str) -> str:
return f"### Needs Attention\n{message}"
def _runtime_banner(resolution: AdapterResolution) -> str:
status = resolution.runtime
active_backend = resolution.selected or "unavailable"
return (
f"Runtime: **{status.requested_mode}** Β· "
f"ZeroGPU preferred: **{status.prefer_zerogpu}** Β· "
f"ZeroGPU runtime available now: **{status.zerogpu_runtime_available}** Β· "
f"ZeroGPU runnable now: **{resolution.zerogpu_runnable}** Β· "
f"Default backend now: **{active_backend}** Β· {resolution.message}"
)
def _starter_spec(starter_key: str | None) -> dict[str, str]:
if starter_key in _STARTER_FLOW_BY_KEY:
return _STARTER_FLOW_BY_KEY[starter_key]
return _STARTER_FLOW_BY_KEY[_DEFAULT_STARTER]
def _mode_summary_markdown(starter_key: str | None, quality_name: str | None) -> str:
starter = _starter_spec(starter_key)
quality = quality_name if quality_name in _QUALITY_GUIDANCE else starter["quality"]
return (
f"**{starter['label']}** Β· {starter['summary']}\n\n"
f"**{quality.title()} mode** β {_QUALITY_GUIDANCE[quality]}\n\n"
f"Capture hint: {starter['capture']}"
)
def _capture_check_markdown(
report: Any, starter_key: str | None, quality_name: str | None
) -> str:
starter = _starter_spec(starter_key)
quality_label = quality_name.title() if isinstance(quality_name, str) else "Draft"
if report.score >= 85:
verdict = "Ready"
elif report.score >= 65:
verdict = "Workable"
else:
verdict = "Needs improvement"
lines = [
f"**{verdict}** Β· Score **{report.score}/100** for **{starter['label']}**.",
f"Current quality: **{quality_label}**.",
f"Capture focus: {starter['capture']}",
]
if report.issues:
lines.append("\n**Checks**")
lines.extend(f"- {item}" for item in report.issues[:4])
else:
lines.append("\n- Capture looks clean enough for a first pass.")
if report.score < 70 and quality_name == "high":
lines.append("\n- Improve the input before using the slowest quality setting.")
return "\n".join(lines)
def _summarize_text(value: object, limit: int = 220) -> str:
text = " ".join(str(value).split())
if len(text) <= limit:
return text
return text[: limit - 3].rstrip() + "..."
def _history_choice_label(summary: dict[str, Any]) -> str:
run_id = str(summary.get("run_id", "unknown"))
adapter = _backend_display_label(summary.get("adapter", "unknown"))
stage = str(summary.get("stage", "unknown"))
score = summary.get("score")
score_text = f"{score}/100" if score is not None else "score n/a"
suffix = " Β· fallback" if summary.get("fallback_reason") else ""
return f"{run_id} Β· {adapter} Β· {stage} Β· {score_text}{suffix}"
def _selected_run_id(choice: str | None) -> str | None:
if not choice:
return None
return choice.split(" Β· ", 1)[0]
def _history_notice_text(items: list[dict[str, Any]]) -> str:
if not items:
return "No local runs yet. Generate once to populate your project history."
latest = items[0]
latest_starter = latest.get("starter_flow") or "Unspecified"
return (
f"{len(items)} local run(s) available. Latest: `{latest['run_id']}` Β· "
f"{_backend_display_label(latest.get('adapter', 'unknown'))} Β· {latest_starter}"
)
def _workspace_guide() -> str:
lines = [
"### Workspace Patterns Merged Into This App",
"",
"- **Starter flows** reduce first-run decision load by pairing outcome-oriented templates with sensible default quality settings.",
"- **Template chips** borrow the best prompt-lab behavior from modern image tools by letting you preload a strong default in one click.",
"- **Project briefs** keep text intent, capture notes, and optional reference docs next to the image evidence so the prompt context stays attached to each run.",
"- **Projects & history** keep prior runs visible in a compact rail and a dedicated reopen tab instead of treating each export as a dead end.",
"- **Repo-local sample packs** keep starter captures inside this repository so the workspace behaves the same on local runs and hosted deployments.",
"- **Visual starter galleries** borrow the strongest parts of browse-heavy creative suites without sacrificing truthful run status or file output state.",
"- **Route-preserving tabs** separate creation, inspection, and guidance without sending the user to a different product surface.",
"",
"### Starter Flows",
]
for starter in _STARTER_FLOWS:
lines.append(
f"- **{starter['label']}**: {starter['summary']} Suggested quality: `{starter['quality']}`."
)
lines.extend(
[
"",
"### What Gets Stored With Each Run",
"",
"- starter flow label",
"- project brief text",
"- optional attached brief filename",
"- selected adapter, quality, fallback reason, and exported artifacts",
]
)
return "\n".join(lines)
def _build_theme() -> Any:
if gr is None: # pragma: no cover
return None
return gr.themes.Base(
primary_hue="blue",
secondary_hue="purple",
neutral_hue="slate",
spacing_size="md",
radius_size="lg",
text_size="lg",
font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "sans-serif"],
font_mono=[
gr.themes.GoogleFont("IBM Plex Mono"),
"ui-monospace",
"monospace",
],
).set(
body_background_fill="#f2f4f8",
background_fill_primary="#ffffff",
background_fill_secondary="#f6f8fb",
block_background_fill="#ffffff",
block_border_width="1px",
block_border_color="rgba(13, 17, 23, 0.10)",
block_shadow="0 4px 12px rgba(0, 0, 0, 0.06)",
button_primary_background_fill="linear-gradient(135deg, #0070f3, #7c3aed)",
button_primary_background_fill_hover="linear-gradient(135deg, #005cd4, #6d28d9)",
button_primary_text_color="white",
button_secondary_background_fill="#f6f8fb",
button_secondary_background_fill_hover="#eef1f6",
button_secondary_text_color="#0d1117",
input_background_fill="#ffffff",
input_border_color="rgba(13, 17, 23, 0.12)",
input_border_color_focus="#0070f3",
loader_color="#0070f3",
block_title_text_weight="700",
)
def build_demo():
if gr is None: # pragma: no cover
raise RuntimeError(f"Gradio is not installed: {GRADIO_IMPORT_ERROR}")
config = load_config()
download_keys = resolve_gradio_download_keys(config.exports.formats)
artifact_row_layout = resolve_artifact_row_layout(config.exports.formats)
orchestrator = ImageEZOrchestrator(config)
job_service = JobService(config)
backend_choices = orchestrator.adapter_choices()
backend_value = (
config.app.adapter if config.app.adapter in backend_choices else "auto"
)
resolution = orchestrator.resolve_adapter(backend_value)
history_runs = orchestrator.store.list_runs(limit=_HISTORY_LIMIT)
history_choices = [_history_choice_label(item) for item in history_runs]
history_default = history_choices[0] if history_choices else None
history_compare_default = (
history_choices[1] if len(history_choices) > 1 else history_default
)
sample_packs = _repo_sample_packs()
with gr.Blocks(title=config.app.title) as demo:
session_state = gr.State({})
with gr.Tabs(elem_classes="workspace-tabs meshy-workspace-tabs"):
with gr.Tab("Model", elem_id="meshy-tab-model"):
with gr.Row(equal_height=False, elem_classes="workspace-layout"):
with gr.Column(scale=8, min_width=760, elem_classes="main-column"):
with gr.Group(elem_classes="workspace-panel composer-panel"):
gr.HTML(_hero_shell_html(
config.app.title,
resolution,
quality_name=config.generation.quality,
))
template_buttons: list[tuple[Any, str]] = []
with gr.Row(
equal_height=False, elem_classes="composer-grid"
):
with gr.Column(
scale=6,
min_width=360,
elem_classes="composer-media-column",
):
project_brief = gr.Textbox(
label="Project brief",
lines=4,
value=_starter_spec(_DEFAULT_STARTER)["brief"],
placeholder="Subject, must-keep details, and target export quality.",
elem_classes="brief-field composer-brief",
)
input_modality = gr.Radio(
label="Input type",
choices=["image", "text"],
value="image",
elem_classes="composer-control input-modality",
)
text_prompt = gr.Textbox(
label="Text-to-3D prompt",
lines=3,
placeholder="Describe the object to generate in 3D (stub path until neural text adapters ship).",
elem_classes="composer-control text-prompt-field",
)
generation_lane = gr.Radio(
label="Generation lane",
choices=["draft", "production", "preview", "refine"],
value="draft",
info="Draft is fastest; production maps to a higher export tier.",
elem_classes="composer-control generation-lane",
)
primary = gr.Image(
label="Primary image",
type="pil",
sources=["upload", "clipboard"],
elem_classes="primary-input composer-primary",
)
with gr.Accordion(
"Repo-local sample captures",
open=False,
elem_classes="sample-capture-accordion",
):
with gr.Row(
equal_height=False,
elem_classes="sample-pack-row",
):
for pack in sample_packs:
with gr.Column(scale=1, min_width=210):
with gr.Group(
elem_classes="sample-pack-surface"
):
gr.HTML(
_sample_pack_header_html(
pack
)
)
gr.Examples(
examples=pack["examples"],
inputs=[primary],
examples_per_page=pack[
"count"
],
)
with gr.Accordion(
"Optional labeled views",
open=False,
elem_classes="views-accordion",
):
with gr.Row(equal_height=False):
front = gr.Image(
label="Front",
type="pil",
sources=["upload", "clipboard"],
)
back = gr.Image(
label="Back",
type="pil",
sources=["upload", "clipboard"],
)
left = gr.Image(
label="Left",
type="pil",
sources=["upload", "clipboard"],
)
right = gr.Image(
label="Right",
type="pil",
sources=["upload", "clipboard"],
)
with gr.Column(
scale=4,
min_width=300,
elem_classes="composer-control-column",
):
with gr.Row(
equal_height=False,
elem_classes="action-row composer-footer",
):
generate = gr.Button(
"Generate Mesh",
variant="primary",
elem_classes="generate-button composer-cta meshy-generate-cta",
)
credit_footer = gr.HTML(
_credit_preview_html("image", "draft"),
elem_classes="credit-footer-shell",
)
gr.Markdown(
"Generate early, then refine with presets or advanced controls.",
elem_classes="subtle-note action-note",
)
starter = gr.Dropdown(
label="Starter flow",
choices=[
item["key"] for item in _STARTER_FLOWS
],
value=_DEFAULT_STARTER,
elem_classes="composer-control",
)
quality_intake_panel = gr.HTML(
_quality_intake_html(config.generation.quality),
elem_classes="quality-intake-shell",
)
quality = gr.Radio(
label="Quality mode",
choices=["draft", "balanced", "high"],
value=config.generation.quality,
elem_classes="quality-pills composer-control",
)
mode_summary = gr.Markdown(
_mode_summary_markdown(
_DEFAULT_STARTER,
config.generation.quality,
),
elem_classes="note-panel compact-note mode-summary",
)
with gr.Accordion(
"Advanced run controls",
open=False,
elem_classes="advanced-accordion",
):
adapter = gr.Dropdown(
label="Backend",
choices=backend_choices,
value=backend_value,
info="auto prefers ZeroGPU and falls back to CPU when ZeroGPU is not usable.",
elem_classes="composer-control",
)
seed = gr.Number(
label="Seed",
value=config.generation.seed,
precision=0,
elem_classes="composer-control",
)
reference_brief = gr.File(
label="Optional reference brief",
type="filepath",
elem_classes="reference-brief",
)
queue_as_job = gr.Checkbox(
label="Queue as background job",
value=False,
info=(
"Submit through the async job queue "
"and poll until complete. Manifest "
"records job_id and async_capable."
),
elem_classes="composer-control",
)
with gr.Row(
equal_height=False,
elem_classes="starter-card-row",
):
for template in _PROMPT_TEMPLATES[:3]:
with gr.Column(scale=1, min_width=210):
with gr.Group(
elem_classes="template-card starter-card"
):
gr.HTML(
_prompt_template_card_html(template)
)
template_button = gr.Button(
f"Use {template['title']}",
variant="secondary",
elem_classes="template-apply",
)
template_buttons.append(
(template_button, str(template["key"]))
)
with gr.Row(
equal_height=False,
elem_classes="text-prompt-template-row",
):
for template in _TEXT_PROMPT_TEMPLATES:
with gr.Column(scale=1, min_width=210):
with gr.Group(
elem_classes="template-card text-template-card"
):
gr.Markdown(
f"**{escape(template['title'])}**\n\n"
f"{escape(str(template['prompt'])[:120])}β¦"
)
text_template_button = gr.Button(
f"Use {template['title']}",
variant="secondary",
elem_classes="text-template-apply",
)
text_template_button.click(
lambda p=template["prompt"], lane=template["lane"]: (
"text",
p,
lane,
),
outputs=[
input_modality,
text_prompt,
generation_lane,
],
)
with gr.Column(scale=4, min_width=340, elem_classes="rail-column"):
with gr.Group(elem_classes="workspace-panel rail-panel"):
gr.HTML(
_surface_header_html(
"Project Rail",
"Keep runtime and history in view",
"Borrow the Grok-style project rail without burying the primary creation flow under a permanent sidebar.",
)
)
create_history_summary = gr.HTML(
_history_overview_html(
history_runs, resolution=resolution
),
elem_classes="history-overview-shell",
)
gr.HTML(
_fallback_notice_html(resolution),
elem_classes="fallback-notice-shell",
)
gr.Markdown(
_runtime_banner(resolution),
elem_classes="status-panel runtime-panel",
)
with gr.Accordion(
"Model Helper",
open=False,
elem_classes="model-helper-accordion",
):
model_helper = gr.Markdown(
_workspace_ui.model_helper_markdown(),
elem_classes="model-helper-panel",
)
apply_bear_preset = gr.Button(
"Use bear-warrior preset",
variant="secondary",
elem_classes="model-helper-apply",
)
with gr.Group(elem_classes="workspace-panel preview-panel"):
gr.HTML(
_surface_header_html(
"Preview",
"Generated geometry",
"The 3D pane stays empty until the same verified mesh files shown below are actually available.",
)
)
model = gr.Model3D(
label="Generated model",
value=None,
clear_color=_MODEL_CLEAR_COLOR,
elem_classes="model-panel",
)
status = gr.Markdown(
"No generated output yet. Generate a run to populate the preview and downloads.",
elem_classes="status-panel",
)
preview_extras = gr.HTML(
elem_classes="preview-extras-shell",
)
with gr.Row(
equal_height=False,
elem_classes="viewer-mesh-op-row",
):
viewer_remesh_btn = gr.Button(
"Remesh",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_analyze_btn = gr.Button(
"Analyze Print",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_repair_btn = gr.Button(
"Repair Print",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_multi_color_btn = gr.Button(
"Multi-Color 3MF",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_unwrap_btn = gr.Button(
"Unwrap UV",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_retexture_btn = gr.Button(
"Edit Texture",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_retry_btn = gr.Button(
"Retry",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_download_btn = gr.Button(
"Download",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_send_print_btn = gr.Button(
"Send to Print",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_send_animate_btn = gr.Button(
"Send to Animate",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
with gr.Row(
equal_height=False,
elem_classes="viewer-boolean-row",
):
viewer_boolean_second_mesh = gr.File(
label="Boolean second mesh",
file_types=[".glb", ".gltf", ".obj", ".stl"],
type="filepath",
elem_classes="viewer-boolean-mesh-file",
)
viewer_boolean_union_btn = gr.Button(
"Boolean Union",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_boolean_difference_btn = gr.Button(
"Boolean Difference",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
viewer_boolean_intersection_btn = gr.Button(
"Boolean Intersect",
variant="secondary",
elem_classes="viewer-mesh-op-btn",
)
stub_html = _workspace_ui.viewer_action_stub_bar_html()
if stub_html:
gr.HTML(stub_html)
with gr.Group(elem_classes="workspace-panel validation-panel"):
gr.HTML(
_surface_header_html(
"Capture Check",
"Inspect the normalized input before spending a run",
"Keep the best part of agent UIs: immediate feedback before the expensive action fires.",
)
)
validation_preview = gr.Image(
label="Normalized preview",
type="pil",
interactive=False,
elem_classes="capture-preview-img",
)
validation_status = gr.Markdown(
"Upload a primary image to preview the normalized input and the capture score before generating.",
elem_classes="status-panel",
)
with gr.Group(elem_classes="workspace-panel output-panel"):
gr.HTML(
_surface_header_html(
"Outputs",
"Collect verified exports",
"Manifest, meshes, and ZIP stay tied to the run, with nothing shown early and nothing faked.",
)
)
create_artifact_files: dict[str, Any] = {}
for row_keys in artifact_row_layout:
with gr.Row(
equal_height=False, elem_classes="artifact-row"
):
for key in row_keys:
create_artifact_files[key] = gr.File(
label=UI_ARTIFACT_LABELS[key],
elem_classes="artifact-file",
)
with gr.Tab("Image", elem_id="meshy-tab-image"):
with gr.Group(elem_classes="workspace-panel meshy-lane-shell"):
gr.HTML(_meshy_lane_panel_html("image"))
gr.Markdown(_workspace_ui.model_helper_markdown())
with gr.Tab("Print", elem_id="meshy-tab-print"):
with gr.Group(elem_classes="workspace-panel meshy-lane-shell"):
gr.HTML(_meshy_lane_panel_html("print"))
with gr.Tab("Animate", elem_id="meshy-tab-animate"):
with gr.Group(elem_classes="workspace-panel meshy-lane-shell"):
gr.HTML(_meshy_lane_panel_html("animate"))
with gr.Tab("Assets", elem_id="meshy-tab-assets"):
history_summary = gr.HTML(
_history_overview_html(history_runs, resolution=resolution),
elem_classes="history-overview-shell",
)
with gr.Row(equal_height=False, elem_classes="history-layout"):
with gr.Column(scale=3, min_width=280):
with gr.Group(elem_classes="workspace-panel history-sidebar"):
gr.HTML(
_surface_header_html(
"Projects",
"Reopen recent runs",
"Keep the strongest Grok-style behavior: recent work stays visible and recoverable while you compare outputs.",
)
)
history_notice = gr.Markdown(
_history_notice_text(history_runs),
elem_classes="status-panel",
)
assets_search = gr.Textbox(
label="Search runs",
placeholder="Run id, starter, adapter, modalityβ¦",
elem_classes="assets-search composer-control",
)
assets_phase_filter = gr.Radio(
label="Phase filter",
choices=_workspace_ui.ASSETS_PHASE_FILTER_LABELS,
value=_workspace_ui.ASSETS_PHASE_FILTER_LABELS[0],
elem_classes="assets-phase-filter composer-control",
)
assets_gallery = gr.HTML(
_workspace_ui.assets_gallery_html(
history_runs,
total_count=len(history_runs),
),
elem_classes="assets-gallery-shell",
)
history_run = gr.Radio(
label="Recent runs",
choices=history_choices,
value=history_default,
elem_classes="history-run-list",
)
with gr.Row(
equal_height=False, elem_classes="history-action-row"
):
history_refresh = gr.Button(
"Refresh",
variant="secondary",
elem_classes="history-action",
)
history_open = gr.Button(
"Open Run",
variant="primary",
elem_classes="history-action",
)
history_compare_run = gr.Radio(
label="Compare with",
choices=history_choices,
value=history_compare_default,
elem_classes="history-run-list",
)
history_compare_btn = gr.Button(
"Compare Runs",
variant="secondary",
elem_classes="history-action",
)
history_compare = gr.Markdown(
"Pick two runs and compare manifest-backed fields.",
elem_classes="history-compare-panel status-panel",
)
history_compare_json = gr.File(
label="Compare diff (JSON)",
elem_classes="artifact-file",
)
history_compare_report = gr.File(
label="Compare report (MD)",
elem_classes="artifact-file",
)
with gr.Column(scale=5, min_width=340):
with gr.Group(elem_classes="workspace-panel history-preview"):
gr.HTML(
_surface_header_html(
"Inspect",
"Run preview",
"The reopen path uses the same verified mesh contract as a fresh generation, not a placeholder substitute.",
)
)
history_model = gr.Model3D(
label="Run preview",
value=None,
clear_color=_MODEL_CLEAR_COLOR,
elem_classes="model-panel",
)
history_inspect = gr.HTML(
elem_classes="history-inspect-shell",
)
history_status = gr.Markdown(
"Select a run and open it to inspect the manifest and exports.",
elem_classes="status-panel",
)
with gr.Column(scale=4, min_width=320):
with gr.Group(elem_classes="workspace-panel history-artifacts"):
gr.HTML(
_surface_header_html(
"Artifacts",
"Recover exported files",
"Everything stays attached to the selected run so comparison and rollback remain explicit.",
)
)
history_artifact_files: dict[str, Any] = {}
for key in download_keys:
history_artifact_files[key] = gr.File(
label=UI_ARTIFACT_LABELS[key],
elem_classes="artifact-file",
)
with gr.Tab("Guide"):
with gr.Group(elem_classes="workspace-panel guide-panel"):
gr.HTML(
_surface_header_html(
"Guide",
"Why this shell now looks different",
"This pass keeps the trustworthy output contract from the recovery fix, then reintroduces higher-fidelity patterns from the five reference tools without bringing back fake-friendly UI behavior.",
)
)
gr.Markdown(_workspace_guide())
def history_updates():
runs = orchestrator.store.list_runs(limit=_HISTORY_LIMIT)
labels = [_history_choice_label(item) for item in runs]
value = labels[0] if labels else None
compare_value = labels[1] if len(labels) > 1 else value
return (
cast(Any, gr).Radio(choices=labels, value=value),
cast(Any, gr).Radio(choices=labels, value=compare_value),
_history_notice_text(runs),
_history_overview_html(runs),
_history_overview_html(runs, resolution=resolution),
_workspace_ui.assets_gallery_html(runs, total_count=len(runs)),
)
def apply_assets_filters(search, phase_label):
runs = orchestrator.store.list_runs(limit=_HISTORY_LIMIT)
phase = _workspace_ui.ASSETS_PHASE_FILTER_BY_LABEL.get(
phase_label,
"all",
)
filtered = _workspace_ui.filter_asset_runs(
runs,
search=search,
phase=phase,
)
labels = [_history_choice_label(item) for item in filtered]
value = labels[0] if labels else None
compare_value = labels[1] if len(labels) > 1 else value
return (
cast(Any, gr).Radio(choices=labels, value=value),
cast(Any, gr).Radio(choices=labels, value=compare_value),
_workspace_ui.assets_filter_notice_text(
filtered,
total_count=len(runs),
search=search,
phase=phase,
),
_history_overview_html(filtered, resolution=resolution),
_workspace_ui.assets_gallery_html(filtered, total_count=len(runs)),
)
def preview_primary(primary_image, starter_key, quality_name):
if primary_image is None:
return (
None,
"Upload a primary image to preview the normalized input and the capture score before generating.",
)
report = validate_image(
primary_image,
minimum_short_side=config.preprocessing.minimum_short_side,
maximum_long_side=config.preprocessing.maximum_long_side,
blur_edge_variance_threshold=config.preprocessing.blur_edge_variance_threshold,
low_contrast_threshold=config.preprocessing.low_contrast_threshold,
)
preview = normalize_image(
primary_image,
size=min(384, config.preprocessing.target_size),
)
return preview, _capture_check_markdown(report, starter_key, quality_name)
def apply_starter(starter_key, current_brief, primary_image):
starter_spec = _starter_spec(starter_key)
brief_value = (
current_brief.strip()
if isinstance(current_brief, str) and current_brief.strip()
else starter_spec["brief"]
)
quality_value = starter_spec["quality"]
preview, status_text = preview_primary(
primary_image, starter_spec["key"], quality_value
)
return (
quality_value,
brief_value,
_mode_summary_markdown(starter_spec["key"], quality_value),
preview,
status_text,
_quality_intake_html(quality_value),
)
def apply_prompt_template(template_key, primary_image):
template = _PROMPT_TEMPLATE_BY_KEY[template_key]
starter_key = str(template["starter"])
quality_value = str(template["quality"])
preview, status_text = preview_primary(
primary_image,
starter_key,
quality_value,
)
return (
starter_key,
str(template["brief"]),
quality_value,
_mode_summary_markdown(starter_key, quality_value),
preview,
status_text,
_quality_intake_html(quality_value),
)
def update_quality_help(quality_name, primary_image, starter_key):
preview, status_text = preview_primary(
primary_image, starter_key, quality_name
)
return (
_mode_summary_markdown(starter_key, quality_name),
preview,
status_text,
_quality_intake_html(quality_name),
)
def compare_history_runs(primary_choice, compare_choice):
empty_exports = (None, None)
def _fail(message: str) -> tuple[str, None, None]:
return message, *empty_exports
run_a = _selected_run_id(primary_choice)
run_b = _selected_run_id(compare_choice)
if not run_a or not run_b:
return _fail(
"Select two runs from **Recent runs** and **Compare with**, "
"then click **Compare Runs**."
)
if run_a == run_b:
return _fail("Choose two different runs to compare.")
try:
left = orchestrator.store.read_manifest(run_a)
right = orchestrator.store.read_manifest(run_b)
except FileNotFoundError as exc:
return _fail(_error_report(str(exc)))
markdown = _manifest_ui.compare_runs_markdown(left, right)
compare_dir = Path(tempfile.gettempdir()) / "imageezgen3d-compare"
compare_dir.mkdir(parents=True, exist_ok=True)
json_path = compare_dir / f"compare_{run_a}_vs_{run_b}.json"
report_path = compare_dir / f"compare_{run_a}_vs_{run_b}.md"
json_path.write_text(
_manifest_ui.compare_runs_json(left, right),
encoding="utf-8",
)
report_path.write_text(markdown, encoding="utf-8")
return markdown, str(json_path), str(report_path)
def open_history_run(history_choice):
empty_artifacts = (None,) * len(download_keys)
run_id = _selected_run_id(history_choice)
if not run_id:
return (
None,
"",
"Select a run to inspect.",
*empty_artifacts,
)
try:
payload = orchestrator.store.read_manifest(run_id)
except FileNotFoundError as exc:
return (
None,
"",
_error_report(str(exc)),
*empty_artifacts,
)
artifacts = payload.get("artifacts", {})
verified_artifacts, missing_keys = _verified_artifact_state(
orchestrator.store,
artifacts,
)
if missing_keys:
return (
None,
_history_inspect_html(payload, missing_keys),
_stale_artifact_report(run_id, missing_keys),
*empty_artifacts,
)
bundle_path = orchestrator.store.archive_run(run_id)
history_model_path = verified_artifacts.get(
"glb"
) or verified_artifacts.get("obj")
return (
history_model_path,
_history_inspect_html(payload, missing_keys),
_format_report(payload),
*artifact_download_values(
verified_artifacts,
download_keys,
bundle_path=str(bundle_path),
),
)
def run_generate(
primary_image,
front_image,
back_image,
left_image,
right_image,
starter_flow,
project_brief_text,
reference_brief_file,
adapter_name,
quality_name,
seed_value,
input_modality_name,
text_prompt_value,
generation_lane_name,
queue_as_job_enabled,
state,
):
state = dict(state or {})
views = {
"front": front_image,
"back": back_image,
"left": left_image,
"right": right_image,
}
resolved_modality = resolve_generation_input_modality(
input_modality_name,
primary_image,
views,
)
fallback_model = state.get("model")
try:
if queue_as_job_enabled:
job_request = build_job_request_from_gradio(
intake_root=config.app.output_dir / "jobs" / "intake",
primary_image=primary_image,
view_images=views,
adapter_name=adapter_name,
quality_name=quality_name,
seed_value=int(seed_value or 0),
project_brief_text=project_brief_text,
starter_flow=starter_flow,
starter_flow_label=_starter_spec(starter_flow)["label"],
reference_brief_file=reference_brief_file,
input_modality_name=input_modality_name,
text_prompt_value=text_prompt_value,
generation_lane_name=generation_lane_name,
)
result = run_via_job_queue(job_service, job_request)
else:
result = orchestrator.generate(
primary_image=primary_image,
view_images=views,
adapter_name=adapter_name,
quality=quality_name,
seed=int(seed_value or 0),
project_brief=project_brief_text,
starter_flow=starter_flow,
starter_flow_label=_starter_spec(starter_flow)["label"],
reference_brief=reference_brief_file,
input_modality=resolved_modality,
prompt_text=text_prompt_value,
lane=generation_lane_name,
)
except (ValueError, RuntimeError) as exc:
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
fallback_model,
_error_report(str(exc)),
"",
*session_artifact_values(state, download_keys),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
state["last_run_id"] = result["run_id"]
artifacts, missing_keys = _verified_artifact_state(
orchestrator.store,
result.get("artifacts"),
)
if missing_keys:
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
None,
_stale_artifact_report(result["run_id"], missing_keys),
"",
*((None,) * len(download_keys)),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
state["model"] = artifacts.get("glb") or artifacts.get("obj")
sync_session_artifact_keys(state, artifacts, download_keys)
state["bundle"] = str(orchestrator.store.archive_run(result["run_id"]))
state["retry_snapshot"] = capture_retry_snapshot(
starter_flow=starter_flow,
project_brief_text=project_brief_text,
reference_brief_file=reference_brief_file,
adapter_name=adapter_name,
quality_name=quality_name,
seed_value=int(seed_value or 0),
input_modality_name=input_modality_name,
text_prompt_value=text_prompt_value,
generation_lane_name=generation_lane_name,
queue_as_job_enabled=queue_as_job_enabled,
)
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
state["model"],
_format_report(result),
_preview_mesh_extras_html(result),
*artifact_download_values(
artifacts,
download_keys,
bundle_path=state["bundle"],
),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
def _viewer_job_error_outputs(
message: str,
state: dict[str, Any],
fallback_model: Any,
*,
preview_extras: str = "",
):
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
fallback_model,
_error_report(message),
preview_extras,
*session_artifact_values(state, download_keys),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
def _finalize_queued_run_result(
result: dict[str, Any],
state: dict[str, Any],
*,
fallback_model: Any,
):
state = dict(state or {})
fallback_model = fallback_model or state.get("model")
state["last_run_id"] = result["run_id"]
artifacts, missing_keys = _verified_artifact_state(
orchestrator.store,
result.get("artifacts"),
)
if missing_keys:
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
fallback_model,
_stale_artifact_report(result["run_id"], missing_keys),
"",
*session_artifact_values(state, download_keys),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
next_model = artifacts.get("glb") or artifacts.get("obj")
if next_model:
state["model"] = next_model
merged_artifacts = {
key: artifacts.get(key) or state.get(key)
for key in download_keys
if key != "bundle" and (artifacts.get(key) or state.get(key))
}
sync_session_artifact_keys(state, merged_artifacts, download_keys)
state["bundle"] = str(orchestrator.store.archive_run(result["run_id"]))
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
state.get("model") or fallback_model,
_format_report(result),
_preview_mesh_extras_html(result),
*artifact_download_values(
merged_artifacts,
download_keys,
bundle_path=state["bundle"],
),
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
def run_viewer_mesh_op(modality: str, state):
state = dict(state or {})
fallback_model = state.get("model")
mesh_path = state.get("model")
if not mesh_path or not Path(mesh_path).is_file():
return _viewer_job_error_outputs(
"Generate a model first, then run viewer mesh operations.",
state,
fallback_model,
)
try:
job_request = build_mesh_op_job_request(modality, str(mesh_path))
result = run_via_job_queue(job_service, job_request)
except (ValueError, RuntimeError) as exc:
return _viewer_job_error_outputs(str(exc), state, fallback_model)
return _finalize_queued_run_result(
result,
state,
fallback_model=fallback_model,
)
def run_viewer_boolean_mesh_op(modality: str, second_mesh_file, state):
state = dict(state or {})
fallback_model = state.get("model")
mesh_path = state.get("model")
if not mesh_path or not Path(mesh_path).is_file():
return _viewer_job_error_outputs(
"Generate a model first, then run boolean mesh operations.",
state,
fallback_model,
)
second_mesh_path = str(second_mesh_file or "").strip()
if not second_mesh_path or not Path(second_mesh_path).is_file():
return _viewer_job_error_outputs(
"Upload a second mesh file, then run a boolean operation.",
state,
fallback_model,
)
try:
job_request = build_mesh_op_job_request(
modality,
str(mesh_path),
second_mesh_path=second_mesh_path,
)
result = run_via_job_queue(job_service, job_request)
except (ValueError, RuntimeError, FileNotFoundError) as exc:
return _viewer_job_error_outputs(str(exc), state, fallback_model)
return _finalize_queued_run_result(
result,
state,
fallback_model=fallback_model,
)
def run_viewer_retexture(
primary_image,
project_brief,
text_prompt,
state,
):
state = dict(state or {})
fallback_model = state.get("model")
mesh_path = state.get("model")
if not mesh_path or not Path(mesh_path).is_file():
return _viewer_job_error_outputs(
"Generate a model first, then run Edit Texture.",
state,
fallback_model,
)
try:
job_request = build_retexture_job_request(
intake_root=config.app.output_dir / "jobs" / "intake",
source_mesh_path=str(mesh_path),
texture_image=primary_image,
prompt_text=text_prompt,
project_brief=project_brief,
)
result = run_via_job_queue(job_service, job_request)
except (ValueError, RuntimeError) as exc:
return _viewer_job_error_outputs(str(exc), state, fallback_model)
return _finalize_queued_run_result(
result,
state,
fallback_model=fallback_model,
)
def run_retry(
primary_image,
front_image,
back_image,
left_image,
right_image,
state,
):
state = dict(state or {})
snapshot = state.get("retry_snapshot")
if not isinstance(snapshot, dict):
return _viewer_job_error_outputs(
"Generate once before retrying the last run settings.",
state,
state.get("model"),
)
return run_generate(
primary_image,
front_image,
back_image,
left_image,
right_image,
snapshot.get("starter_flow"),
snapshot.get("project_brief_text"),
snapshot.get("reference_brief_file"),
snapshot.get("adapter_name"),
snapshot.get("quality_name"),
snapshot.get("seed_value"),
snapshot.get("input_modality_name"),
snapshot.get("text_prompt_value"),
snapshot.get("generation_lane_name"),
snapshot.get("queue_as_job_enabled"),
state,
)
def run_viewer_refresh_downloads(state):
state = dict(state or {})
fallback_model = state.get("model")
if not fallback_model:
return _viewer_job_error_outputs(
"Generate once to populate verified downloads.",
state,
fallback_model,
)
artifact_values = session_artifact_values(state, download_keys)
if not any(artifact_values):
return _viewer_job_error_outputs(
"No verified download files are available for this session yet.",
state,
fallback_model,
)
(
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
) = history_updates()
return (
fallback_model,
"### Downloads ready\nUse the Outputs panel file components below.",
"",
*artifact_values,
state,
history_dropdown,
history_compare_dropdown,
history_message,
history_overview,
create_overview,
assets_gallery_html,
)
def run_viewer_send_to_animate(state):
state = dict(state or {})
fallback_model = state.get("model")
mesh_path = state.get("model")
if not mesh_path or not Path(mesh_path).is_file():
return _viewer_job_error_outputs(
"Generate a model first, then send it to the Animate lane.",
state,
fallback_model,
)
try:
job_request = build_animate_job_request(str(mesh_path))
result = run_via_job_queue(job_service, job_request)
except (ValueError, RuntimeError) as exc:
return _viewer_job_error_outputs(str(exc), state, fallback_model)
return _finalize_queued_run_result(
result,
state,
fallback_model=fallback_model,
)
def update_credit_preview(
input_modality_name,
generation_lane_name,
quality_name,
):
return _credit_preview_html(
input_modality_name,
generation_lane_name,
quality_name=quality_name,
)
def apply_bear_warrior_preset():
preset = _workspace_ui.BEAR_WARRIOR_PRESET
prompt = str(preset["prompt"])
return (
"text",
prompt,
"production",
prompt,
_workspace_ui.model_helper_markdown(preset),
_credit_preview_html("text", "production"),
)
primary.change(
preview_primary,
inputs=[primary, starter, quality],
outputs=[validation_preview, validation_status],
)
starter.change(
apply_starter,
inputs=[starter, project_brief, primary],
outputs=[
quality,
project_brief,
mode_summary,
validation_preview,
validation_status,
quality_intake_panel,
],
)
quality.change(
update_quality_help,
inputs=[quality, primary, starter],
outputs=[
mode_summary,
validation_preview,
validation_status,
quality_intake_panel,
],
)
for template_button, template_key in template_buttons:
template_button.click(
lambda primary_image, template_key=template_key: apply_prompt_template(
template_key,
primary_image,
),
inputs=[primary],
outputs=[
starter,
project_brief,
quality,
mode_summary,
validation_preview,
validation_status,
quality_intake_panel,
],
)
generate.click(
run_generate,
inputs=[
primary,
front,
back,
left,
right,
starter,
project_brief,
reference_brief,
adapter,
quality,
seed,
input_modality,
text_prompt,
generation_lane,
queue_as_job,
session_state,
],
outputs=[
model,
status,
preview_extras,
*[create_artifact_files[key] for key in download_keys],
session_state,
history_run,
history_compare_run,
history_notice,
history_summary,
create_history_summary,
assets_gallery,
],
api_name="generate",
)
viewer_mesh_op_outputs = [
model,
status,
preview_extras,
*[create_artifact_files[key] for key in download_keys],
session_state,
history_run,
history_compare_run,
history_notice,
history_summary,
create_history_summary,
assets_gallery,
]
for mesh_op_button, mesh_op_modality in (
(viewer_remesh_btn, "remesh"),
(viewer_analyze_btn, "print-analyze"),
(viewer_repair_btn, "print-repair"),
(viewer_multi_color_btn, "print-multi-color"),
(viewer_unwrap_btn, "unwrap-uv"),
):
mesh_op_button.click(
lambda state, mesh_op_modality=mesh_op_modality: run_viewer_mesh_op(
mesh_op_modality,
state,
),
inputs=[session_state],
outputs=viewer_mesh_op_outputs,
)
for boolean_button, boolean_modality in (
(viewer_boolean_union_btn, "boolean-union"),
(viewer_boolean_difference_btn, "boolean-difference"),
(viewer_boolean_intersection_btn, "boolean-intersection"),
):
boolean_button.click(
lambda state, second_mesh, mesh_op_modality=boolean_modality: run_viewer_boolean_mesh_op(
mesh_op_modality,
second_mesh,
state,
),
inputs=[session_state, viewer_boolean_second_mesh],
outputs=viewer_mesh_op_outputs,
)
viewer_retexture_btn.click(
run_viewer_retexture,
inputs=[primary, project_brief, text_prompt, session_state],
outputs=viewer_mesh_op_outputs,
)
viewer_retry_btn.click(
run_retry,
inputs=[primary, front, back, left, right, session_state],
outputs=viewer_mesh_op_outputs,
)
viewer_download_btn.click(
run_viewer_refresh_downloads,
inputs=[session_state],
outputs=viewer_mesh_op_outputs,
)
viewer_send_print_btn.click(
lambda state: run_viewer_mesh_op("print-analyze", state),
inputs=[session_state],
outputs=viewer_mesh_op_outputs,
)
viewer_send_animate_btn.click(
run_viewer_send_to_animate,
inputs=[session_state],
outputs=viewer_mesh_op_outputs,
)
credit_preview_inputs = [input_modality, generation_lane, quality]
for control in (input_modality, generation_lane, quality):
control.change(
update_credit_preview,
inputs=credit_preview_inputs,
outputs=[credit_footer],
)
apply_bear_preset.click(
apply_bear_warrior_preset,
outputs=[
input_modality,
text_prompt,
generation_lane,
project_brief,
model_helper,
credit_footer,
],
)
assets_filter_outputs = [
history_run,
history_compare_run,
history_notice,
history_summary,
assets_gallery,
]
assets_filter_inputs = [assets_search, assets_phase_filter]
for assets_control in assets_filter_inputs:
assets_control.change(
apply_assets_filters,
inputs=assets_filter_inputs,
outputs=assets_filter_outputs,
)
history_refresh.click(
apply_assets_filters,
inputs=assets_filter_inputs,
outputs=assets_filter_outputs,
api_name="assets_filter_updates",
)
history_compare_btn.click(
compare_history_runs,
inputs=[history_run, history_compare_run],
outputs=[
history_compare,
history_compare_json,
history_compare_report,
],
api_name="compare_history_runs",
)
history_open.click(
open_history_run,
inputs=[history_run],
outputs=[
history_model,
history_inspect,
history_status,
*[history_artifact_files[key] for key in download_keys],
],
)
demo.load(
history_updates,
outputs=[
history_run,
history_compare_run,
history_notice,
history_summary,
create_history_summary,
assets_gallery,
],
)
return demo
_CSS = """
/* βββ Design tokens βββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
:root {
--iez-ink: #0d1117;
--iez-ink-2: #1a2332;
--iez-muted: #556070;
--iez-muted-2: #8494a7;
--iez-line: rgba(13, 17, 23, 0.10);
--iez-line-2: rgba(13, 17, 23, 0.06);
--iez-surface: #ffffff;
--iez-surface-2: #f6f8fb;
--iez-surface-3: #eef1f6;
--iez-panel: rgba(255, 255, 255, 0.96);
--iez-accent: #0070f3;
--iez-accent-2: #00a67e;
--iez-accent-3: #7c3aed;
--iez-accent-glow: rgba(0, 112, 243, 0.22);
--iez-warm: #e96515;
--r-card: 20px;
--r-panel: 24px;
--r-xl: 32px;
--shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
--shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
--shadow-md: 0 8px 28px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
--shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.10), 0 8px 20px rgba(0, 0, 0, 0.06);
--shadow-xl: 0 32px 80px rgba(0, 0, 0, 0.14), 0 12px 32px rgba(0, 0, 0, 0.07);
--font-display: clamp(2.4rem, 4vw + 1rem, 5rem);
--font-section: clamp(1.6rem, 2.5vw, 2.4rem);
--font-card: clamp(1.3rem, 1.8vw, 1.8rem);
}
/* βββ Container & page βββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.gradio-container {
max-width: 1500px !important;
padding: 0 !important;
background: #f2f4f8 !important;
}
/* βββ Tabs βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.workspace-tabs {
gap: 0;
padding: 0;
}
.workspace-tabs > .tab-nav {
position: sticky;
top: 0;
z-index: 100;
padding: 0 32px;
border-bottom: 1px solid var(--iez-line);
background: rgba(255, 255, 255, 0.92);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(18px);
}
.workspace-tabs button[role="tab"] {
min-height: 52px;
padding: 0 20px;
border-radius: 0 !important;
border: none !important;
border-bottom: 2px solid transparent !important;
background: transparent !important;
color: var(--iez-muted) !important;
font-weight: 600;
font-size: 0.95rem;
letter-spacing: 0.01em;
transition: color 0.18s, border-color 0.18s;
box-shadow: none !important;
}
.workspace-tabs button[role="tab"][aria-selected="true"] {
border-bottom-color: var(--iez-accent) !important;
color: var(--iez-ink) !important;
background: transparent !important;
box-shadow: none !important;
}
.workspace-tabs button[role="tab"]:hover:not([aria-selected="true"]) {
color: var(--iez-ink-2) !important;
}
.workspace-tabs > .tabitem {
padding: 28px 32px 48px;
}
/* βββ Hero βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.hero-shell {
display: grid;
grid-template-columns: 1fr;
gap: 0;
padding: 14px 22px;
border-radius: var(--r-xl);
margin-bottom: 10px;
overflow: hidden;
position: relative;
background: var(--iez-surface);
border: 1px solid var(--iez-line);
box-shadow: var(--shadow-md);
color: var(--iez-ink);
}
.hero-shell::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(135deg, rgba(0, 112, 243, 0.04) 0%, rgba(124, 58, 237, 0.02) 100%);
pointer-events: none;
}
.hero-shell::after {
display: none;
}
.hero-copy {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
gap: 0;
}
.hero-copy .surface-eyebrow {
display: block;
text-transform: uppercase;
letter-spacing: 0.16em;
font-size: 0.70rem;
font-weight: 700;
color: var(--iez-accent);
margin: 0 0 6px;
}
.hero-copy h1 {
margin: 0 0 8px;
font-size: clamp(1.7rem, 2.1vw + 0.7rem, 2.6rem);
line-height: 0.92;
letter-spacing: -0.055em;
color: var(--iez-ink);
font-weight: 800;
}
.hero-copy-text {
max-width: 56ch;
margin: 0 0 6px;
color: var(--iez-muted);
font-size: 1.05rem;
line-height: 1.7;
}
.hero-chip-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 10px;
}
.hero-chip {
padding: 9px 13px;
border-radius: 12px;
background: var(--iez-surface-2);
border: 1px solid var(--iez-line);
flex: 1 1 120px;
}
.hero-chip-label {
display: block;
text-transform: uppercase;
letter-spacing: 0.13em;
font-size: 0.65rem;
font-weight: 700;
color: var(--iez-muted-2);
margin: 0 0 5px;
}
.hero-chip-value {
display: block;
font-size: 0.92rem;
font-weight: 800;
color: var(--iez-ink);
}
/* βββ Main layout βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.workspace-layout,
.history-layout {
gap: 24px;
align-items: start;
}
.main-column,
.rail-column {
display: grid;
gap: 20px;
align-content: start;
}
/* βββ Panels ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.workspace-panel {
border-radius: var(--r-panel);
border: 1px solid var(--iez-line);
background: var(--iez-surface);
box-shadow: var(--shadow-sm);
padding: 28px;
}
/* βββ Surface headers βββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.surface-header-copy {
margin-bottom: 22px;
}
.surface-header-copy .surface-eyebrow {
display: block;
text-transform: uppercase;
letter-spacing: 0.16em;
font-size: 0.70rem;
font-weight: 700;
color: var(--iez-accent);
margin: 0 0 8px;
}
.surface-header-copy h2 {
margin: 0;
font-size: var(--font-section);
line-height: 0.94;
letter-spacing: -0.04em;
color: var(--iez-ink);
font-weight: 800;
}
.surface-header-copy .surface-copy {
margin: 10px 0 0;
color: var(--iez-muted);
font-size: 0.96rem;
line-height: 1.65;
}
/* βββ Composer panel (dark creation area) βββββββββββββββββββββββββββββββββ */
.composer-panel {
position: relative;
overflow: hidden;
border: none !important;
background: var(--iez-surface) !important;
box-shadow: var(--shadow-lg) !important;
}
.composer-panel .hero-shell {
padding: 10px 18px;
margin-bottom: 6px;
}
.composer-panel .hero-copy h1 {
font-size: clamp(1.4rem, 1.5vw + 0.6rem, 2rem) !important;
}
.composer-panel::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(135deg, rgba(0, 112, 243, 0.02) 0%, rgba(124, 58, 237, 0.01) 100%);
pointer-events: none;
}
.composer-panel::after {
display: none;
}
.composer-panel .surface-header-copy .surface-eyebrow {
color: var(--iez-accent) !important;
}
.composer-panel .surface-header-copy h2 {
color: var(--iez-ink) !important;
font-size: clamp(1.65rem, 1.7vw + 0.9rem, 2.2rem);
max-width: 22ch;
}
.composer-panel .surface-header-copy .surface-copy {
color: var(--iez-muted) !important;
max-width: 62ch;
}
/* Composer sub-grid */
.composer-grid {
gap: 20px;
position: relative;
z-index: 1;
align-items: stretch;
}
.starter-card-row {
position: relative;
z-index: 1;
gap: 10px;
margin: 12px 0 0;
}
.starter-card .template-card-copy {
min-height: unset;
padding: 14px 16px 12px;
gap: 6px;
}
.starter-card .template-card-meta {
display: none;
}
.starter-card .template-card-summary {
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-clamp: 2;
font-size: 0.88rem;
}
.sample-capture-accordion {
border-radius: 18px;
overflow: hidden;
border: 1px solid var(--iez-line);
background: var(--iez-surface-2);
}
.sample-capture-accordion > button {
min-height: 48px !important;
background: var(--iez-surface-3) !important;
color: var(--iez-ink) !important;
border-bottom: 1px solid var(--iez-line) !important;
}
.mode-summary {
margin-top: 2px;
}
.composer-media-column,
.composer-control-column {
display: grid;
gap: 14px;
align-content: start;
}
/* Light Gradio blocks inside composer */
.composer-panel .block,
.composer-panel fieldset.block,
.composer-panel .form .block {
border-radius: 18px !important;
border: 1px solid var(--iez-line) !important;
background: var(--iez-surface) !important;
box-shadow: none !important;
}
.composer-panel [data-testid="block-info"],
.composer-panel [data-testid="block-label"],
.composer-panel label span {
color: var(--iez-muted) !important;
font-weight: 700 !important;
text-transform: uppercase;
letter-spacing: 0.12em;
font-size: 0.72rem !important;
}
.composer-panel textarea,
.composer-panel input,
.composer-panel .secondary-wrap,
.composer-panel .wrap-inner,
.composer-panel .input-container {
background: transparent !important;
color: var(--iez-ink) !important;
}
.composer-panel textarea::placeholder,
.composer-panel input::placeholder {
color: var(--iez-muted-lighter) !important;
}
.composer-panel .composer-brief textarea {
min-height: 128px !important;
font-size: 0.98rem !important;
line-height: 1.6 !important;
font-weight: 400;
}
.composer-panel .composer-primary,
.composer-panel .reference-brief {
min-height: 140px;
}
.composer-panel .primary-input .empty,
.composer-panel .reference-brief .empty {
min-height: 120px !important;
}
/* Quality pill radio buttons */
.composer-panel .quality-pills .wrap {
gap: 9px;
}
.composer-panel .quality-pills label {
border-radius: 99px !important;
border: 1px solid var(--iez-line) !important;
background: var(--iez-surface-2) !important;
padding: 9px 18px !important;
transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.composer-panel .quality-pills label.selected {
background: rgba(0, 112, 243, 0.72) !important;
border-color: rgba(0, 112, 243, 0.60) !important;
box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.22);
}
.composer-panel .quality-pills label span {
color: var(--iez-ink) !important;
font-weight: 600;
}
.composer-panel .quality-pills label.selected span {
color: white !important;
}
/* Compact notes inside composer */
.compact-support-grid {
margin-top: 0;
}
.composer-panel .note-panel {
background: var(--iez-surface-2) !important;
border: 1px solid var(--iez-line) !important;
border-radius: 16px;
}
.composer-panel .note-panel * {
color: var(--iez-muted) !important;
}
.composer-panel .note-panel strong {
color: var(--iez-ink) !important;
}
/* Composer footer */
.composer-footer {
position: relative;
z-index: 1;
margin-top: 8px;
padding: 10px 14px !important;
border-radius: 18px;
border: 1px solid var(--iez-line);
background: var(--iez-surface-2);
align-items: center;
}
.composer-cta {
min-width: 230px;
}
.advanced-accordion,
.helper-accordion {
border-radius: 14px !important;
border: 1px solid var(--iez-line) !important;
background: var(--iez-surface-2) !important;
}
.advanced-accordion > button,
.helper-accordion > button {
min-height: 44px !important;
font-size: 0.84rem !important;
letter-spacing: 0.05em;
text-transform: uppercase;
color: var(--iez-muted) !important;
}
.action-note,
.action-note * {
color: var(--iez-muted) !important;
font-size: 0.88rem !important;
}
.action-note.block {
padding: 4px 0 !important;
min-height: 0 !important;
background: transparent !important;
border: none !important;
box-shadow: none !important;
}
/* Generate button */
.generate-button {
flex: 0 0 220px;
min-height: 52px !important;
font-size: 1rem !important;
font-weight: 700 !important;
letter-spacing: 0.02em;
border-radius: 14px !important;
background: linear-gradient(135deg, #0070f3, #7c3aed) !important;
border: none !important;
box-shadow: 0 8px 28px rgba(0, 112, 243, 0.36) !important;
transition: box-shadow 0.18s, transform 0.12s;
}
.generate-button:hover {
box-shadow: 0 12px 36px rgba(0, 112, 243, 0.50) !important;
transform: translateY(-1px);
}
.generate-button:active {
transform: translateY(0px);
box-shadow: 0 6px 18px rgba(0, 112, 243, 0.30) !important;
}
.action-note {
display: flex;
align-items: center;
margin: 0;
}
/* βββ Prompt Lab (template cards) βββββββββββββββββββββββββββββββββββββββββ */
.template-panel {
background: var(--iez-surface) !important;
border-color: var(--iez-line) !important;
}
.launch-kits-accordion,
.discover-accordion {
border-radius: var(--r-card);
border: 1px solid var(--iez-line);
background: var(--iez-surface);
box-shadow: var(--shadow-sm);
overflow: hidden;
}
.launch-kits-accordion > button,
.discover-accordion > button {
min-height: 52px !important;
padding: 0 18px !important;
background: var(--iez-surface-2) !important;
color: var(--iez-ink) !important;
font-weight: 700 !important;
border-bottom: 1px solid var(--iez-line) !important;
text-transform: none;
letter-spacing: 0.01em;
}
.launch-kits-accordion > button:hover,
.discover-accordion > button:hover {
background: var(--iez-surface-3) !important;
}
.template-panel .surface-header-copy .surface-copy,
.discover-panel .surface-header-copy .surface-copy {
max-width: 70ch;
}
.template-grid-row {
gap: 16px;
}
.template-card {
height: 100%;
border-radius: var(--r-card) !important;
border: 1px solid var(--iez-line) !important;
overflow: hidden !important;
background: transparent !important;
box-shadow: var(--shadow-sm) !important;
transition: box-shadow 0.2s, transform 0.15s;
}
.template-card:hover {
box-shadow: var(--shadow-md) !important;
transform: translateY(-2px);
}
.template-card .block {
padding: 0 !important;
overflow: hidden !important;
border: none !important;
background: transparent !important;
border-radius: 0 !important;
box-shadow: none !important;
}
.template-card-copy {
position: relative;
display: flex;
flex-direction: column;
gap: 10px;
min-height: 230px;
padding: 22px 22px 20px;
overflow: hidden;
}
.template-card-copy::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(150deg, var(--tc-from, #f0f5ff), var(--tc-to, #e8f0ff));
z-index: 0;
}
.template-card-copy::after {
content: "";
position: absolute;
top: -30%; right: -20%;
width: 200px; height: 200px;
border-radius: 50%;
background: radial-gradient(circle, rgba(255,255,255,0.70), transparent 65%);
pointer-events: none;
}
.template-card-copy > * {
position: relative;
z-index: 1;
}
/* Card tone overrides */
.template-tone-fast-silhouette { --tc-from: #eef4ff; --tc-to: #e0ecff; }
.template-tone-studio-product { --tc-from: #fff4ee; --tc-to: #ffeae0; }
.template-tone-collectible-pose { --tc-from: #f0faf2; --tc-to: #e2f5e8; }
.template-tone-museum-study { --tc-from: #faf5f0; --tc-to: #f0e8e0; }
.template-tone-multi-view-review { --tc-from: #edf3ff; --tc-to: #e4edff; }
.template-card-top {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.template-card-badge {
display: inline-block;
padding: 3px 10px;
border-radius: 99px;
background: rgba(0, 0, 0, 0.07);
border: 1px solid rgba(0, 0, 0, 0.08);
font-size: 0.68rem;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
color: var(--iez-ink) !important;
}
.template-card-quality {
font-size: 0.72rem;
font-weight: 700;
letter-spacing: 0.10em;
text-transform: uppercase;
color: var(--iez-accent) !important;
}
.template-card-copy h3 {
margin: 6px 0 0 !important;
font-size: var(--font-card) !important;
line-height: 0.94 !important;
letter-spacing: -0.045em !important;
color: var(--iez-ink) !important;
font-weight: 800 !important;
}
.template-card-summary {
color: var(--iez-muted) !important;
font-size: 0.96rem;
line-height: 1.55;
}
.template-card-meta {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 6px;
margin-top: auto;
padding-top: 14px;
border-top: 1px solid rgba(0, 0, 0, 0.07);
}
.template-card-meta span:first-child {
color: var(--iez-ink) !important;
font-weight: 700;
font-size: 0.88rem;
}
.template-card-meta span:last-child {
color: var(--iez-muted-2) !important;
font-size: 0.84rem;
line-height: 1.5;
}
.template-card .template-apply {
width: 100%;
margin: 0 !important;
border-radius: 0 0 var(--r-card) var(--r-card) !important;
background: var(--iez-ink) !important;
color: white !important;
min-height: 52px;
font-size: 0.94rem !important;
font-weight: 700 !important;
letter-spacing: 0.02em;
border: none !important;
box-shadow: none !important;
transition: background 0.18s;
}
.template-card .template-apply:hover {
background: linear-gradient(135deg, #0070f3, #7c3aed) !important;
}
/* βββ Discover panel (sample packs) βββββββββββββββββββββββββββββββββββββββ */
.discover-panel {
background: var(--iez-surface-2) !important;
border-color: var(--iez-line) !important;
}
.discover-note {
margin: 0 0 16px 0;
}
.sample-pack-row {
gap: 16px;
}
.sample-pack-surface {
border-radius: var(--r-card) !important;
border: 1px solid var(--iez-line) !important;
overflow: hidden !important;
background: var(--iez-surface) !important;
box-shadow: var(--shadow-sm) !important;
}
.sample-pack-surface .block {
border: none !important;
background: transparent !important;
box-shadow: none !important;
padding: 0 !important;
}
.sample-pack-head {
padding: 18px 18px 12px;
border-bottom: 1px solid var(--iez-line-2);
}
.sample-pack-count {
display: block;
text-transform: uppercase;
letter-spacing: 0.14em;
font-size: 0.68rem;
font-weight: 700;
color: var(--iez-warm);
margin: 0 0 5px;
}
.sample-pack-head h3 {
margin: 0 0 4px !important;
font-size: 1.20rem !important;
font-weight: 800 !important;
letter-spacing: -0.03em;
color: var(--iez-ink);
}
.sample-pack-head p {
margin: 0 !important;
font-size: 0.88rem !important;
color: var(--iez-muted) !important;
line-height: 1.55;
}
.discover-panel .gallery {
display: grid !important;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1px;
background: var(--iez-line);
}
.discover-panel .gallery-item {
overflow: hidden !important;
border-radius: 0 !important;
border: none !important;
background: var(--iez-surface) !important;
min-height: 110px;
aspect-ratio: 1;
}
.discover-panel .gallery-item img {
display: block;
width: 100% !important;
height: 100% !important;
object-fit: cover !important;
transition: transform 0.22s;
}
.discover-panel .gallery-item:hover img {
transform: scale(1.05);
}
/* βββ Rail column: compact, secondary to composer βββββββββββββββββββββββββ */
.rail-column .workspace-panel {
padding: 18px 20px;
box-shadow: var(--shadow-xs) !important;
}
.rail-column .surface-header-copy {
margin-bottom: 12px;
}
.rail-column .surface-header-copy .surface-copy {
display: none;
}
.rail-column .surface-header-copy h2 {
font-size: 1.08rem !important;
line-height: 1.15;
letter-spacing: -0.02em;
}
.rail-column .surface-header-copy .surface-eyebrow {
margin-bottom: 4px;
font-size: 0.65rem;
}
.rail-column .status-panel {
padding: 10px 12px;
font-size: 0.84rem;
line-height: 1.55;
}
.rail-column .preview-panel .status-panel,
.rail-column .validation-panel .status-panel {
padding: 8px 10px;
font-size: 0.80rem;
line-height: 1.45;
}
.main-column .composer-panel {
box-shadow: var(--shadow-lg) !important;
}
/* βββ Rail panel (project history) ββββββββββββββββββββββββββββββββββββββββ */
.rail-panel {
position: sticky;
top: 68px;
}
.history-overview {
display: grid;
gap: 14px;
}
.history-overview-copy .surface-eyebrow {
display: block;
text-transform: uppercase;
letter-spacing: 0.16em;
font-size: 0.70rem;
font-weight: 700;
color: var(--iez-accent);
margin: 0 0 8px;
}
.history-overview-copy h2 {
margin: 0 !important;
font-size: 1.30rem !important;
font-weight: 800;
letter-spacing: -0.04em;
color: var(--iez-ink);
}
.history-overview-copy p,
.history-overview-latest {
margin: 6px 0 0 !important;
color: var(--iez-muted) !important;
font-size: 0.90rem;
line-height: 1.6;
}
.history-overview-latest {
color: var(--iez-ink) !important;
font-weight: 600 !important;
}
.history-stat-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
}
.history-stat-card {
padding: 12px 14px;
border-radius: 14px;
background: var(--iez-surface-2);
border: 1px solid var(--iez-line);
}
.history-stat-label {
display: block;
text-transform: uppercase;
letter-spacing: 0.13em;
font-size: 0.65rem;
font-weight: 700;
color: var(--iez-muted-2);
margin: 0 0 5px;
}
.history-stat-card strong {
display: block;
font-size: 0.92rem;
font-weight: 800;
color: var(--iez-ink);
}
.history-run-list {
margin-top: 10px;
}
.history-action-row {
gap: 10px;
margin-top: 4px;
}
/* βββ Manifest-driven run cards βββββββββββββββββββββββββββββββββββββββββββ */
.run-status-card,
.artifact-strip {
border-radius: 16px;
padding: 14px 16px;
margin: 8px 0 10px;
border: 1px solid var(--iez-line) !important;
background: var(--iez-surface-2) !important;
box-shadow: none !important;
}
.run-status-card * ,
.artifact-strip * {
color: var(--iez-ink) !important;
font-size: 0.86rem !important;
line-height: 1.55 !important;
}
.run-status-chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
.run-status-chip,
.draft-quality-badge {
display: inline-block;
padding: 4px 10px;
border-radius: 999px;
background: rgba(0, 112, 243, 0.08);
border: 1px solid rgba(0, 112, 243, 0.14);
font-size: 0.78rem !important;
font-weight: 600;
}
.run-status-chip.fallback {
background: rgba(245, 158, 11, 0.10);
border-color: rgba(245, 158, 11, 0.22);
}
.artifact-strip ul {
margin: 8px 0 0 1.1rem !important;
padding: 0 !important;
}
.artifact-ok {
color: var(--iez-ink) !important;
}
.artifact-missing {
color: #b45309 !important;
}
/* βββ Quality intake ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.quality-intake {
border-radius: 16px;
padding: 14px 16px;
margin: 8px 0 10px;
background: linear-gradient(135deg, rgba(0, 112, 243, 0.05), rgba(124, 58, 237, 0.05)) !important;
border: 1px solid rgba(0, 112, 243, 0.14) !important;
box-shadow: none !important;
}
.quality-intake * {
color: var(--iez-ink) !important;
font-size: 0.86rem !important;
line-height: 1.55 !important;
}
.quality-intake ul {
margin: 8px 0 0 1.1rem !important;
padding: 0 !important;
}
/* βββ Fallback notice βββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.fallback-notice {
border-radius: 16px;
padding: 14px 16px;
margin-bottom: 10px;
background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(234, 88, 12, 0.06)) !important;
border: 1px solid rgba(245, 158, 11, 0.22) !important;
box-shadow: none !important;
}
.fallback-notice * {
color: var(--iez-ink) !important;
font-size: 0.86rem !important;
line-height: 1.55 !important;
}
/* βββ Runtime banner ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.runtime-panel {
border-radius: 16px;
padding: 14px 16px;
background: linear-gradient(135deg, rgba(0, 112, 243, 0.06), rgba(0, 166, 126, 0.06)) !important;
border: 1px solid rgba(0, 112, 243, 0.12) !important;
box-shadow: none !important;
}
.runtime-panel * {
color: var(--iez-ink) !important;
font-size: 0.86rem !important;
}
/* βββ Preview / validation / output panels ββββββββββββββββββββββββββββββββ */
.preview-panel,
.validation-panel,
.output-panel {
border-color: var(--iez-line) !important;
}
.note-panel,
.status-panel {
padding: 14px 16px;
border-radius: 14px;
background: var(--iez-surface-2);
border: 1px solid var(--iez-line);
font-size: 0.92rem;
line-height: 1.65;
color: var(--iez-muted);
}
.subtle-note {
color: var(--iez-muted-2);
font-size: 0.88rem;
}
/* βββ Artifact files ββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.artifact-row {
gap: 6px;
}
.artifact-file {
min-width: 0;
min-height: 48px;
overflow: hidden !important;
border: 1px solid var(--iez-line) !important;
border-radius: 14px !important;
background: var(--iez-surface-2) !important;
box-shadow: none !important;
}
.artifact-file label {
padding: 8px 12px 0 !important;
color: var(--iez-muted) !important;
font-size: 0.80rem !important;
font-weight: 700 !important;
text-transform: uppercase;
letter-spacing: 0.10em;
}
.artifact-file .empty.large {
min-height: 26px !important;
height: 26px !important;
margin-top: 0 !important;
padding: 0 !important;
}
.artifact-file .empty.large .wrap > span,
.artifact-file .empty.large .wrap > p,
.artifact-file .empty.large .wrap > div:not(.icon-wrap) {
display: none !important;
}
.artifact-file .icon {
opacity: 0.35;
transform: scale(0.65);
margin: 0 auto;
}
.artifact-file table {
font-size: 0.84rem;
}
.artifact-file table tr {
background: transparent !important;
}
/* βββ Capture preview βββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.capture-preview-img > div[data-testid="empty"],
.capture-preview-img .empty {
min-height: 72px !important;
height: 72px !important;
}
.capture-preview-img .empty .wrap span,
.capture-preview-img .empty .wrap p {
display: none !important;
}
/* βββ 3D Model viewer βββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.model-panel canvas,
.model-panel model-viewer {
min-height: 84px;
border-radius: 16px;
}
.model-panel > .wrap > .empty,
.model-panel > div > .empty,
.model-panel .empty.large,
.model-panel .empty.unpadded_box,
.model-panel [data-testid="empty"] {
min-height: 84px !important;
height: 84px !important;
padding: 0 !important;
}
/* βββ Meshy workspace extras ββββββββββββββββββββββββββββββββββββββββββββββ */
.meshy-workspace-tabs > .tab-nav button[role="tab"][aria-selected="true"] {
border-bottom-color: #84cc16 !important;
}
.credit-footer-shell .credit-footer {
margin-top: 12px;
padding: 14px 16px;
border-radius: 14px;
border: 1px solid var(--iez-line);
background: linear-gradient(135deg, rgba(132, 204, 22, 0.08), rgba(0, 112, 243, 0.04));
}
.credit-footer-value {
margin: 4px 0;
font-size: 1.05rem;
}
.credit-footer-task,
.credit-footer-note {
margin: 4px 0 0;
color: var(--iez-muted);
font-size: 0.88rem;
}
.meshy-generate-cta {
background: linear-gradient(135deg, #0070f3, #84cc16) !important;
}
.preview-extras-shell,
.history-inspect-shell {
display: grid;
gap: 14px;
}
.mesh-stats-card,
.pbr-channel-strip,
.viewer-action-bar,
.meshy-lane-panel {
padding: 14px 16px;
border-radius: 14px;
border: 1px solid var(--iez-line);
background: var(--iez-surface-2);
}
.mesh-stats-list {
margin: 8px 0 0;
padding-left: 18px;
}
.pbr-channel-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
gap: 8px;
margin-top: 8px;
}
.pbr-tile {
padding: 10px;
border-radius: 10px;
border: 1px dashed var(--iez-line);
text-align: center;
font-size: 0.78rem;
}
.pbr-tile-ready {
border-style: solid;
background: var(--iez-surface);
}
.pbr-label {
display: block;
font-weight: 700;
margin-bottom: 4px;
}
.pbr-file {
display: block;
color: var(--iez-muted);
overflow-wrap: anywhere;
}
.viewer-mesh-op-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 4px;
}
.assets-gallery-shell,
.assets-gallery {
display: grid;
gap: 12px;
}
.assets-group {
display: grid;
gap: 8px;
}
.assets-run-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 8px;
}
.assets-run-card {
padding: 12px;
border-radius: 12px;
border: 1px solid var(--iez-line);
background: var(--iez-surface);
}
.assets-run-id {
margin: 0;
font-family: var(--font-mono, monospace);
font-size: 0.78rem;
overflow-wrap: anywhere;
}
.assets-run-meta,
.assets-run-flow {
margin: 6px 0 0;
font-size: 0.82rem;
color: var(--iez-muted);
}
.assets-run-badges {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 8px;
}
.assets-run-badge {
display: inline-flex;
padding: 2px 8px;
border-radius: 999px;
border: 1px solid var(--iez-line);
font-size: 0.72rem;
font-weight: 600;
}
.assets-run-badge-fallback {
border-color: rgba(196, 127, 44, 0.35);
color: #9a6700;
}
.assets-gallery-empty {
padding: 12px 14px;
border-radius: 12px;
border: 1px dashed var(--iez-line);
color: var(--iez-muted);
}
.viewer-action-row {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.viewer-action-chip {
display: inline-flex;
align-items: center;
padding: 6px 10px;
border-radius: 999px;
border: 1px solid var(--iez-line);
background: var(--iez-surface);
font-size: 0.82rem;
font-weight: 600;
}
.viewer-action-note,
.meshy-lane-copy {
margin: 10px 0 0;
color: var(--iez-muted);
font-size: 0.9rem;
line-height: 1.55;
}
.model-helper-panel {
font-size: 0.92rem;
}
/* βββ Misc Gradio overrides βββββββββββββββββββββββββββββββββββββββββββββββ */
.gradio-model3d,
.image-container,
.file-preview-holder {
min-height: 0 !important;
}
.file-preview {
overflow-wrap: anywhere;
}
button {
min-height: 40px;
}
/* βββ History tab βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.history-sidebar,
.history-preview,
.history-artifacts {
border-color: var(--iez-line) !important;
}
.history-artifacts .artifact-file {
margin-bottom: 8px;
}
/* βββ Guide tab βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
.guide-panel {
max-width: 860px;
}
/* βββ Responsive ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
@media (max-width: 1180px) {
.hero-shell,
.workspace-layout,
.history-layout {
grid-template-columns: 1fr;
}
.rail-panel {
position: static;
}
.hero-shell {
grid-template-columns: 1fr;
}
}
@media (max-width: 900px) {
.workspace-tabs > .tabitem {
padding: 20px 18px 40px;
}
.hero-shell {
padding: 20px 18px;
}
.workspace-panel {
padding: 20px;
}
.composer-grid {
grid-template-columns: 1fr;
}
.template-grid-row {
grid-template-columns: 1fr;
}
.history-stat-grid {
grid-template-columns: 1fr 1fr;
}
}
@media (max-width: 640px) {
.workspace-tabs > .tab-nav {
padding: 0 14px;
}
.workspace-tabs > .tabitem {
padding: 14px 12px 32px;
}
.hero-shell {
padding: 24px 20px;
border-radius: 20px;
}
.hero-copy h1 {
font-size: 2.2rem;
}
.workspace-panel {
padding: 16px;
border-radius: 18px;
}
.discover-panel .gallery {
grid-template-columns: 1fr;
}
.history-stat-grid {
grid-template-columns: 1fr;
}
.hero-chip-row {
grid-template-columns: repeat(2, minmax(0, 1fr));
display: grid;
}
}
"""
demo = build_demo()
if __name__ == "__main__":
launch_config = load_config().launch
launch_kwargs = {
"server_name": launch_config.host,
"share": launch_config.share,
"theme": _build_theme(),
"css": _CSS,
}
if not running_on_hugging_face_space():
launch_kwargs["server_port"] = launch_config.port
demo.queue(
max_size=launch_config.queue_max_size,
default_concurrency_limit=launch_config.default_concurrency_limit,
).launch(**launch_kwargs)
from __future__ import annotations
import sys
import tempfile
from html import escape
from pathlib import Path
from typing import Any, cast
_SRC_DIR = Path(__file__).resolve().parent / "src"
if str(_SRC_DIR) not in sys.path:
sys.path.insert(0, str(_SRC_DIR))
GRADIO_IMPORT_ERROR: Exception | None = None
try:
import gradio as gr
except Exception as exc: # pragma: no cover - exercised only when app deps missing
gr = None # type: ignore[assignment]
GRADIO_IMPORT_ERROR = exc
else:
GRADIO_IMPORT_ERROR = None
from imageezgen3d.config import load_config # noqa: E402
from imageezgen3d.exporters import make_box_mesh, write_glb # noqa: E402
from imageezgen3d import manifest_ui as _manifest_ui # noqa: E402
from imageezgen3d.orchestrator import ( # noqa: E402
AdapterResolution,
ImageEZOrchestrator,
)
from imageezgen3d.jobs import JobService # noqa: E402
from imageezgen3d.jobs.gradio_bridge import ( # noqa: E402
build_animate_job_request,
build_job_request_from_gradio,
build_mesh_op_job_request,
build_retexture_job_request,
capture_retry_snapshot,
resolve_generation_input_modality,
run_via_job_queue,
)
from imageezgen3d.preprocess import normalize_image, validate_image # noqa: E402
from imageezgen3d.runtime import running_on_hugging_face_space # noqa: E402
from imageezgen3d.gradio_artifact_layout import ( # noqa: E402
UI_ARTIFACT_LABELS,
artifact_download_values,
resolve_artifact_row_layout,
resolve_gradio_download_keys,
session_artifact_values,
sync_session_artifact_keys,
)
from imageezgen3d.storage import RunStore # noqa: E402
from imageezgen3d import workspace_ui as _workspace_ui # noqa: E402
_EXAMPLE_SPECS = (
{
"filename": "teal_block.png",
"color": (31, 147, 139),
"label": "Block",
"pack": "shape-basics",
"shape": "block",
},
{
"filename": "red_vase.png",
"color": (191, 57, 72),
"label": "Vase",
"pack": "shape-basics",
"shape": "vase",
},
{
"filename": "cobalt_canister.png",
"color": (53, 91, 196),
"label": "Canister",
"pack": "product-focus",
"shape": "canister",
},
{
"filename": "amber_bottle.png",
"color": (196, 127, 44),
"label": "Bottle",
"pack": "product-focus",
"shape": "bottle",
},
{
"filename": "mint_figurine.png",
"color": (85, 168, 131),
"label": "Figurine",
"pack": "character-forms",
"shape": "figurine",
},
{
"filename": "stone_bust.png",
"color": (122, 126, 139),
"label": "Bust",
"pack": "character-forms",
"shape": "bust",
},
)
_STARTER_FLOWS = (