Progress strip + views in the right column; hide stale models; disable SSR (login-form flash)
Browse filesFiles changed (3)
- app.py+8-4
- model_view.py+7-1
- progress_panel.py+47-27
638 unmodified lines63964064164264364464564625 unmodified lines6726736746756766776786797 unmodified lines687688689690691638 unmodified linesseed, randomize, faces, texture_size, steps = _settings(randomize_default=True)with gr.Column(elem_classes="u3d-examples"):_examples(show_example, [subject, panel, view, seed])panel.render()with gr.Column(scale=6):view.render()glb_file.render()# The panel is the progress display, so Gradio's generic overlays are hidden.25 unmodified linesseed2, randomize2, faces2, texture_size2, steps2 = _settings(randomize_default=False)with gr.Column(elem_classes="u3d-examples"):_examples(show_image_example, [image, panel2, view2, seed2])panel2.render()with gr.Column(scale=6):view2.render()glb_file2.render()btn2.click(7 unmodified linesif __name__ == "__main__":# The 3D views fetch generated and example GLBs through Gradio's file route.demo.queue(default_concurrency_limit=4).launch(css=CSS, allowed_paths=[str(OUT_DIR), str(EX_DIR)])638 unmodified lines63964064164264364464564625 unmodified lines6726736746756766776786797 unmodified lines687688689690691692693694695638 unmodified linesseed, randomize, faces, texture_size, steps = _settings(randomize_default=True)with gr.Column(elem_classes="u3d-examples"):_examples(show_example, [subject, panel, view, seed])with gr.Column(scale=6):panel.render()view.render()glb_file.render()# The panel is the progress display, so Gradio's generic overlays are hidden.25 unmodified linesseed2, randomize2, faces2, texture_size2, steps2 = _settings(randomize_default=False)with gr.Column(elem_classes="u3d-examples"):_examples(show_image_example, [image, panel2, view2, seed2])with gr.Column(scale=6):panel2.render()view2.render()glb_file2.render()btn2.click(7 unmodified linesif __name__ == "__main__":# The 3D views fetch generated and example GLBs through Gradio's file route. Server-side# rendering is off: on this Space its renderer cannot reach the app's API and serves# Gradio's login form ("Could not get API info") until the browser replaces it.demo.queue(default_concurrency_limit=4).launch(css=CSS, allowed_paths=[str(OUT_DIR), str(EX_DIR)], ssr_mode=False,)
129 unmodified lines13013113213313413513612 unmodified lines149150151152153154129 unmodified lines"auto-rotate": "", "auto-rotate-delay": "0", "rotation-per-second": "15deg",};for (const [k, val] of Object.entries(attrs)) v.setAttribute(k, val);v.addEventListener("load", () => { if (state.objectUrl && v.getAttribute("src") === state.objectUrl) overlay(null); });v.addEventListener("error", () => {if (state.objectUrl) overlay("This browser couldn't display the model. You can still download it.", null, true);});12 unmodified linesif (key === state.key) { overlay(...state.overlay); button(...state.button); return; }state.key = key;state.blob = null;v.removeAttribute("src");if (state.objectUrl) { URL.revokeObjectURL(state.objectUrl); state.objectUrl = null; }if (!info) { overlay("Your 3D model will appear here"); button("Download .glb", false); return; }129 unmodified lines13013113213313413513613713813914014112 unmodified lines154155156157158159160129 unmodified lines"auto-rotate": "", "auto-rotate-delay": "0", "rotation-per-second": "15deg",};for (const [k, val] of Object.entries(attrs)) v.setAttribute(k, val);// Hidden until the current model has loaded: removing `src` does not clear a model that// is already displayed, so the previous result would otherwise show under a new run.v.style.opacity = "0";v.addEventListener("load", () => {if (state.objectUrl && v.getAttribute("src") === state.objectUrl) { v.style.opacity = "1"; overlay(null); }});v.addEventListener("error", () => {if (state.objectUrl) overlay("This browser couldn't display the model. You can still download it.", null, true);});12 unmodified linesif (key === state.key) { overlay(...state.overlay); button(...state.button); return; }state.key = key;state.blob = null;v.style.opacity = "0";v.removeAttribute("src");if (state.objectUrl) { URL.revokeObjectURL(state.objectUrl); state.objectUrl = null; }if (!info) { overlay("Your 3D model will appear here"); button("Download .glb", false); return; }
12 unmodified lines131415161718192021222324252663 unmodified lines9091929394959697989910010110210310410510610710811 unmodified lines12012112212312412512632 unmodified lines15916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818923 unmodified lines21321421521621721821912 unmodified linesVIEWS = (("front", "Front", 0), ("right", "Right", 90), ("back", "Back", 180), ("left", "Left", 270))_LATER_STEPS = (("angles", "Camera angles", "Qwen-Image-Edit-2511 + Multiple-Angles LoRA", "Generates the right, back and left views"),("model", "3D model", "UniForge3D on ZeroGPU", "Fuses the four views into a textured mesh"),)STEPS = (("image", "Image", "Krea 2 Turbo", "Draws the object on a white background"),) + _LATER_STEPSIMAGE_STEPS = (("image", "Front view", "your image", "Background removed automatically, then used as the front view"),("angles", "Other views", "Qwen-Image-Edit-2511 + Multiple-Angles LoRA","Generated automatically from your image: right, back and left"),_LATER_STEPS[1],)# Shown in the empty view slots before the first run of the Image → 3D tab.63 unmodified linesitems = list(self.steps.values()) + list(self.views.values())return tuple((i.state, i.note, i.thumb is not None) for i in items) + (self.error,)def html(self):rows = []for index, (key, title, model, idle) in enumerate(self.step_info, 1):item = self.steps[key]note = item.note or idlerows.append(f'<li class="u3d-step is-{item.state}">'f'<span class="u3d-icon" aria-hidden="true">{index}</span>'f'<div class="u3d-body"><div class="u3d-title">{title}'f'<span class="u3d-model">{html.escape(model)}</span></div>'f'<div class="u3d-note">{html.escape(note)}</div></div>'f"{_timer(item)}</li>")tiles = []active = any(item.started is not None for item in [*self.steps.values(), *self.views.values()])for key, label, azimuth in VIEWS:11 unmodified lineserror = f'<div class="u3d-error" role="alert">{html.escape(self.error)}</div>' if self.error else ""return ('<div class="u3d-panel">'f'<ol class="u3d-steps">{"".join(rows)}</ol>'f'<div class="u3d-views">{"".join(tiles)}</div>'f"{error}</div>")32 unmodified lines"""CSS = """.u3d-panel { display: flex; flex-direction: column; gap: 14px; font-size: 14px; color: var(--body-text-color); }.u3d-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }.u3d-step { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; margin: 0; }.u3d-icon {width: 24px; height: 24px; border-radius: 50%; box-sizing: border-box;display: grid; place-items: center; font-size: 12px; font-weight: 600;border: 2px solid var(--border-color-primary); color: var(--body-text-color-subdued);}.u3d-body { min-width: 0; }.u3d-title { font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }.u3d-model { font-weight: 400; font-size: 12px; color: var(--body-text-color-subdued); }.u3d-note { color: var(--body-text-color-subdued); margin-top: 2px; overflow-wrap: anywhere; }.u3d-time { font-variant-numeric: tabular-nums; color: var(--body-text-color-subdued); white-space: nowrap; padding-top: 2px; }.u3d-step.is-running .u3d-icon, .u3d-step.is-queued .u3d-icon {color: transparent; border-color: var(--border-color-primary); border-top-color: var(--color-accent);animation: u3d-spin 0.9s linear infinite;}.u3d-step.is-queued .u3d-icon { animation-duration: 2.4s; }.u3d-step.is-running .u3d-note, .u3d-step.is-queued .u3d-note { color: var(--body-text-color); }.u3d-step.is-done .u3d-icon { background: var(--color-accent); border-color: var(--color-accent); color: #fff; font-size: 0; }.u3d-step.is-done .u3d-icon::after { content: "✓"; font-size: 13px; }.u3d-step.is-failed .u3d-icon { border-color: var(--error-icon-color, #dc2626); color: var(--error-icon-color, #dc2626); font-size: 0; }.u3d-step.is-failed .u3d-icon::after { content: "✕"; font-size: 12px; }.u3d-step.is-failed .u3d-note { color: var(--error-text-color, #dc2626); }.u3d-views { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }.u3d-view { margin: 0; display: flex; flex-direction: column; gap: 4px; }23 unmodified lines@media (prefers-reduced-motion: reduce) {.u3d-step .u3d-icon, .u3d-thumb::before { animation: none !important; }}@media (max-width: 480px) { .u3d-views { grid-template-columns: repeat(2, minmax(0, 1fr)); } }"""# Keyframes must go in the page-level CSS: Gradio nests a component's css_template inside its12 unmodified lines1314151617181920212223242563 unmodified lines899091929394959697989910010110210310410510610710810911011111211311411511611711811912012111 unmodified lines13313413513613713813914032 unmodified lines17317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420523 unmodified lines22923023123223323423523623723823912 unmodified linesVIEWS = (("front", "Front", 0), ("right", "Right", 90), ("back", "Back", 180), ("left", "Left", 270))_LATER_STEPS = (("angles", "Camera angles", "Qwen-Image-Edit-2511 adds the right, back and left views"),("model", "3D model", "UniForge3D builds the textured 3D model"),)STEPS = (("image", "Image", "Krea 2 draws the object"),) + _LATER_STEPSIMAGE_STEPS = (("image", "Front view", "The background is removed automatically"),("angles", "Other views", "The right, back and left views are generated from your image"),_LATER_STEPS[1],)# Shown in the empty view slots before the first run of the Image → 3D tab.63 unmodified linesitems = list(self.steps.values()) + list(self.views.values())return tuple((i.state, i.note, i.thumb is not None) for i in items) + (self.error,)def status(self):"""(state, text) of the line under the strip: the active or failed step's note, thefinal note when done, else what the pipeline does."""items = [self.steps[key] for key, *_ in self.step_info]for item in items:if item.state == "failed":return "failed", item.notefor item in items:if item.state in ("queued", "running"):return item.state, item.noteif all(item.state == "done" for item in items):return "done", items[-1].notereturn "idle", " → ".join(idle for *_, idle in self.step_info)def html(self):strip = []for index, (key, title, _) in enumerate(self.step_info, 1):item = self.steps[key]if index > 1:previous = self.steps[self.step_info[index - 2][0]]strip.append(f'<li class="u3d-link is-{previous.state}" aria-hidden="true"></li>')strip.append(f'<li class="u3d-step is-{item.state}">'f'<span class="u3d-icon" aria-hidden="true">{index}</span>'f'<div class="u3d-body"><span class="u3d-title">{title}</span>{_timer(item)}</div></li>')state, text = self.status()tiles = []active = any(item.started is not None for item in [*self.steps.values(), *self.views.values()])for key, label, azimuth in VIEWS:11 unmodified lineserror = f'<div class="u3d-error" role="alert">{html.escape(self.error)}</div>' if self.error else ""return ('<div class="u3d-panel">'f'<ol class="u3d-steps">{"".join(strip)}</ol>'f'<div class="u3d-status is-{state}">{html.escape(text)}</div>'f'<div class="u3d-views">{"".join(tiles)}</div>'f"{error}</div>")32 unmodified lines"""CSS = """.u3d-panel { display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--body-text-color); }.u3d-steps { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 8px; }.u3d-step { display: flex; align-items: center; gap: 8px; margin: 0; flex: none; }.u3d-link { flex: 1 1 auto; min-width: 12px; height: 2px; margin: 0; border-radius: 1px; background: var(--border-color-primary); }.u3d-link.is-done { background: var(--color-accent); }.u3d-icon {width: 24px; height: 24px; border-radius: 50%; box-sizing: border-box; flex: none;display: grid; place-items: center; font-size: 12px; font-weight: 600;border: 2px solid var(--border-color-primary); color: var(--body-text-color-subdued);}.u3d-body { display: flex; flex-direction: column; line-height: 1.2; }.u3d-title { font-weight: 600; white-space: nowrap; }.u3d-time { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--body-text-color-subdued); white-space: nowrap; min-height: 14px; }.u3d-step.is-waiting .u3d-title { color: var(--body-text-color-subdued); }.u3d-status { font-size: 13px; line-height: 1.4; color: var(--body-text-color-subdued); overflow-wrap: anywhere; }.u3d-status.is-running, .u3d-status.is-queued { color: var(--body-text-color); }.u3d-status.is-failed { color: var(--error-text-color, #dc2626); }.u3d-step.is-running .u3d-icon, .u3d-step.is-queued .u3d-icon {color: transparent; border-color: var(--border-color-primary); border-top-color: var(--color-accent);animation: u3d-spin 0.9s linear infinite;}.u3d-step.is-queued .u3d-icon { animation-duration: 2.4s; }.u3d-step.is-done .u3d-icon { background: var(--color-accent); border-color: var(--color-accent); color: #fff; font-size: 0; }.u3d-step.is-done .u3d-icon::after { content: "✓"; font-size: 13px; }.u3d-step.is-failed .u3d-icon { border-color: var(--error-icon-color, #dc2626); color: var(--error-icon-color, #dc2626); font-size: 0; }.u3d-step.is-failed .u3d-icon::after { content: "✕"; font-size: 12px; }.u3d-views { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }.u3d-view { margin: 0; display: flex; flex-direction: column; gap: 4px; }23 unmodified lines@media (prefers-reduced-motion: reduce) {.u3d-step .u3d-icon, .u3d-thumb::before { animation: none !important; }}@media (max-width: 480px) {.u3d-views { grid-template-columns: repeat(2, minmax(0, 1fr)); }.u3d-steps { gap: 6px; }.u3d-title { white-space: normal; }}"""# Keyframes must go in the page-level CSS: Gradio nests a component's css_template inside its
app.py+8-4
model_view.py+7-1
progress_panel.py+47-27