Spaces:
Paused
Paused
Download studio.html from PrunaAI/P-Q-Image-2.1-DWD: direct link, hf CLI and curl.
- Browser
- Download file 42.5 kB
-
https://huggingface.co/spaces/PrunaAI/P-Q-Image-2.1-DWD/resolve/main/studio.html
- Command line
-
hf download hf://spaces/PrunaAI/P-Q-Image-2.1-DWD/studio.html
-
curl -L -o studio.html https://huggingface.co/spaces/PrunaAI/P-Q-Image-2.1-DWD/resolve/main/studio.html
42.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>DWD Studio</title> | |
| <link rel="preconnect" href="https://fonts.googleapis.com" /> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet" /> | |
| <style> | |
| :root { | |
| --bg: #120b1b; --panel: #171021; --panel2: #1d1429; --raised: #251b34; | |
| --border: rgba(74,57,98,0.75); --hairline: rgba(255,255,255,0.08); | |
| --text: #fafafa; --muted: #a3a3a3; --dim: #71717a; | |
| --accent: #9334e9; --accent2: #8f35ff; --accent-soft: rgba(147,52,233,0.14); | |
| --lavender: #d8b4fe; --link: #bf8bff; | |
| --glow: radial-gradient(ellipse 60% 35% at 50% -5%, rgba(147,52,233,0.18), transparent 55%); | |
| --stage-base: #0e0a16; --stage-square: #171221; --thumb-bg: #120c1c; | |
| --radius: 10px; | |
| } | |
| body.light { | |
| --bg: #f6f3fa; --panel: #ffffff; --panel2: #f6f3fa; --raised: #f3eef8; | |
| --border: rgba(126,34,206,0.16); --hairline: rgba(24,24,27,0.08); | |
| --text: #18181b; --muted: #71717a; --dim: #a1a1aa; | |
| --accent: #9334e9; --accent2: #7c22ce; --accent-soft: rgba(147,52,233,0.10); | |
| --lavender: #7e22ce; --link: #6d28d9; | |
| --glow: radial-gradient(ellipse 60% 35% at 50% -5%, rgba(147,52,233,0.10), transparent 55%); | |
| --stage-base: #e9e4f2; --stage-square: #f8f5fc; --thumb-bg: #f3eef8; | |
| } | |
| * { margin: 0; padding: 0; box-sizing: border-box; } | |
| [hidden] { display: none ; } | |
| body { | |
| font-family: "Inter", ui-sans-serif, system-ui, sans-serif; | |
| background: var(--bg); background-image: var(--glow); background-repeat: no-repeat; | |
| background-attachment: fixed; | |
| color: var(--text); height: 100vh; | |
| display: flex; flex-direction: column; overflow: hidden; | |
| font-size: 13px; -webkit-font-smoothing: antialiased; | |
| } | |
| .topbar { | |
| display: flex; align-items: center; gap: 14px; padding: 8px 16px; | |
| background: var(--panel); border-bottom: 1px solid var(--hairline); flex-shrink: 0; | |
| } | |
| .brand { font-weight: 700; font-size: 0.95rem; white-space: nowrap; letter-spacing: -0.02em; display: flex; align-items: center; } | |
| .brand img { height: 26px; margin-right: 10px; } | |
| .studio-badge { | |
| font-size: 0.6rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; | |
| color: var(--lavender); border: 1px solid var(--border); border-radius: 999px; | |
| padding: 2px 8px; margin-left: 10px; background: var(--accent-soft); | |
| } | |
| .mode-tabs { display: flex; gap: 2px; background: var(--panel2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; } | |
| .mode-tabs button { | |
| border: none; border-radius: 7px; padding: 6px 16px; font-weight: 550; font-size: 0.82rem; | |
| background: transparent; color: var(--muted); cursor: pointer; transition: color 0.15s, background 0.15s; | |
| font-family: inherit; | |
| } | |
| .mode-tabs button:hover { color: var(--text); } | |
| .mode-tabs button.active { background: var(--raised); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.45); } | |
| body.light .mode-tabs button.active { box-shadow: 0 1px 3px rgba(88,28,135,0.15); } | |
| .spacer { flex: 1; } | |
| .ml-badge { color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 500; transition: color 0.15s; white-space: nowrap; } | |
| .ml-badge:hover { color: var(--text); } | |
| .ml-badge-img { display: inline-flex; align-items: center; } | |
| .ml-badge-img img { height: 20px; display: block; } | |
| .ml-badge-img:hover { opacity: 0.85; } | |
| .ml-cta { | |
| color: var(--lavender); text-decoration: none; font-size: 0.8rem; font-weight: 600; | |
| padding: 5px 13px; border: 1px solid var(--accent); border-radius: 999px; | |
| background: var(--accent-soft); transition: filter 0.15s; white-space: nowrap; | |
| } | |
| .ml-cta:hover { filter: brightness(1.2); } | |
| .theme-toggle { | |
| width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; | |
| background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0; | |
| display: inline-flex; align-items: center; justify-content: center; | |
| transition: color 0.15s, background 0.15s; | |
| } | |
| .theme-toggle:hover { color: var(--text); background: var(--panel2); } | |
| .theme-toggle svg { width: 17px; height: 17px; } | |
| .theme-toggle .theme-icon-moon { display: none; } | |
| .theme-toggle[data-mode="light"] .theme-icon-sun { display: none; } | |
| .theme-toggle[data-mode="light"] .theme-icon-moon { display: block; } | |
| .main { display: flex; flex: 1; min-height: 0; } | |
| .rail { | |
| width: 52px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; | |
| gap: 6px; padding: 10px 0; background: var(--panel); border-right: 1px solid var(--hairline); | |
| } | |
| .rail button { | |
| width: 38px; height: 38px; border: 1px solid transparent; border-radius: 8px; | |
| background: transparent; color: var(--muted); cursor: pointer; | |
| display: flex; align-items: center; justify-content: center; | |
| transition: color 0.15s, background 0.15s; | |
| } | |
| .rail button:hover { background: var(--panel2); color: var(--text); } | |
| .rail button.active { color: var(--accent2); background: var(--accent-soft); } | |
| .viewport { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: auto; position: relative; } | |
| .workflow-view { position: absolute; inset: 0; padding: 12px; } | |
| .workflow-view iframe { width: 100%; height: 100%; border: none; border-radius: 10px; background: var(--stage-base); } | |
| .doc-grid { flex: 1; min-height: 0; display: flex; gap: 16px; width: 100%; align-items: stretch; justify-content: center; padding: 20px 20px 10px; } | |
| .doc { | |
| flex: 1; min-width: 0; max-width: 640px; display: flex; flex-direction: column; | |
| background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; | |
| } | |
| .doc figcaption { | |
| padding: 8px 12px; font-size: 0.62rem; font-weight: 650; letter-spacing: 0.12em; | |
| color: var(--dim); border-bottom: 1px solid var(--hairline); text-transform: uppercase; | |
| display: flex; align-items: center; | |
| } | |
| .doc .stage { | |
| position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; | |
| overflow: hidden; background-color: var(--stage-base); | |
| background-image: | |
| linear-gradient(45deg, var(--stage-square) 25%, transparent 25%), | |
| linear-gradient(-45deg, var(--stage-square) 25%, transparent 25%), | |
| linear-gradient(45deg, transparent 75%, var(--stage-square) 75%), | |
| linear-gradient(-45deg, transparent 75%, var(--stage-square) 75%); | |
| background-size: 20px 20px; | |
| background-position: 0 0, 0 10px, 10px -10px, -10px 0; | |
| } | |
| .doc img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; } | |
| .doc img.zoomed { max-width: none; max-height: none; } | |
| .doc .stage.scrollable { overflow: auto; justify-content: flex-start; align-items: flex-start; } | |
| .drop-hint { color: var(--dim); font-size: 0.85rem; text-align: center; padding: 20px; } | |
| .drop-hint b { color: var(--muted); display: block; margin-bottom: 6px; } | |
| .zoom-btn { | |
| margin-left: auto; border: 1px solid var(--border); background: transparent; color: var(--muted); | |
| border-radius: 5px; font-size: 0.62rem; padding: 2px 8px; cursor: pointer; letter-spacing: 0.08em; | |
| font-family: inherit; | |
| } | |
| .zoom-btn:hover { color: var(--text); border-color: var(--accent); } | |
| .doc-bar { | |
| display: flex; align-items: center; gap: 10px; padding: 6px 12px; | |
| border-top: 1px solid var(--hairline); background: var(--panel); | |
| font-size: 0.72rem; color: var(--muted); flex-shrink: 0; | |
| } | |
| .doc-bar button { | |
| border: 1px solid var(--border); background: transparent; color: var(--muted); | |
| border-radius: 5px; padding: 3px 10px; font-size: 0.68rem; cursor: pointer; letter-spacing: 0.06em; | |
| font-family: inherit; | |
| } | |
| .doc-bar button:hover, .doc-bar button.active { color: var(--text); border-color: var(--accent); } | |
| .doc-bar button.active { background: var(--accent-soft); color: var(--lavender); } | |
| .split-wrap { position: absolute; inset: 0; overflow: hidden; } | |
| .split-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; } | |
| .split-divider { | |
| position: absolute; top: 0; bottom: 0; width: 3px; background: var(--accent); | |
| cursor: ew-resize; z-index: 5; box-shadow: 0 0 8px rgba(147,52,233,0.6); | |
| } | |
| .split-divider::after { | |
| content: "◂ ▸"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); | |
| background: var(--accent); color: white; border-radius: 999px; padding: 4px 7px; | |
| font-size: 0.6rem; white-space: nowrap; | |
| } | |
| .history-strip { | |
| display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; flex-shrink: 0; | |
| background: var(--panel); border-top: 1px solid var(--hairline); align-items: center; | |
| } | |
| .history-strip .hlabel { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.14em; color: var(--dim); text-transform: uppercase; white-space: nowrap; } | |
| .history-chip { | |
| width: 52px; height: 52px; border-radius: 6px; border: 1px solid var(--border); | |
| overflow: hidden; cursor: pointer; flex-shrink: 0; position: relative; | |
| } | |
| .history-chip:hover { border-color: var(--accent); } | |
| .history-chip img { width: 100%; height: 100%; object-fit: cover; } | |
| .history-chip .hseed { | |
| position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.65); | |
| color: #ddd; font-size: 0.52rem; padding: 1px 3px; text-align: center; | |
| } | |
| body.light .history-chip .hseed { background: rgba(255,255,255,0.78); color: #3f3f46; } | |
| .panels { | |
| width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; | |
| padding: 12px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--hairline); | |
| } | |
| .panel { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; } | |
| .panel-title { font-size: 0.62rem; font-weight: 650; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; margin-bottom: 10px; cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; } | |
| .panel .panel-title::after { content: "▾"; font-size: 0.7rem; color: var(--dim); } | |
| .panel.collapsed .panel-title::after { content: "▸"; } | |
| .panel.collapsed .panel-body { display: none; } | |
| .panel label { display: block; font-size: 0.72rem; font-weight: 550; color: var(--muted); margin: 10px 0 4px; } | |
| .panel label:first-of-type { margin-top: 0; } | |
| textarea, input[type="text"], input[type="number"], select { | |
| width: 100%; background: var(--raised); color: var(--text); border: 1px solid var(--border); | |
| border-radius: 7px; padding: 8px 10px; font-family: inherit; font-size: 0.83rem; resize: vertical; | |
| transition: border-color 0.15s, box-shadow 0.15s; | |
| } | |
| select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; } | |
| textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px var(--accent-soft); } | |
| textarea.code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.72rem; } | |
| textarea[readonly] { color: var(--muted); } | |
| .row { display: flex; gap: 8px; align-items: center; } | |
| .row > * { flex: 1; } | |
| .switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; } | |
| .switch input { display: none; } | |
| .switch .sw { | |
| display: inline-block; | |
| width: 34px; height: 20px; border-radius: 999px; background: var(--raised); | |
| border: 1px solid var(--border); position: relative; flex-shrink: 0; transition: background 0.18s, border-color 0.18s; | |
| } | |
| .switch .sw::after { | |
| content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; | |
| border-radius: 50%; background: var(--muted); transition: transform 0.18s, background 0.18s; | |
| } | |
| .switch input:checked + .sw { background: var(--accent); border-color: var(--accent); } | |
| .switch input:checked + .sw::after { transform: translateX(14px); background: #fff; } | |
| .switch .sw-label { font-size: 0.75rem; color: var(--muted); } | |
| .layer-row { | |
| display: flex; align-items: center; gap: 10px; padding: 6px 8px; | |
| border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; | |
| background: var(--raised); | |
| } | |
| .layer-row .thumb { | |
| width: 40px; height: 40px; border-radius: 4px; object-fit: cover; flex-shrink: 0; | |
| background: var(--thumb-bg); border: 1px solid var(--border); | |
| display: flex; align-items: center; justify-content: center; | |
| color: var(--dim); font-size: 0.65rem; text-align: center; | |
| } | |
| .layer-row .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 3px; } | |
| .layer-row .lname { flex: 1; font-size: 0.78rem; color: var(--text); } | |
| .layer-row .lsub { font-size: 0.62rem; color: var(--dim); display: block; } | |
| .ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; } | |
| .ref-slot { | |
| height: 64px; border: 1px dashed var(--border); border-radius: 6px; | |
| display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; | |
| color: var(--dim); font-size: 0.68rem; background: var(--raised); text-align: center; | |
| } | |
| .ref-slot:hover { border-color: var(--accent); } | |
| .ref-slot img { width: 100%; height: 100%; object-fit: cover; } | |
| .hint { font-size: 0.68rem; color: var(--dim); margin-top: 8px; line-height: 1.4; } | |
| #examples { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; } | |
| .ex-chip { | |
| border: 1px solid var(--border); border-radius: 8px; cursor: pointer; flex-shrink: 0; | |
| background: var(--raised); padding: 7px 10px; text-align: left; | |
| display: flex; align-items: center; justify-content: space-between; gap: 8px; | |
| transition: border-color 0.15s; font-family: inherit; | |
| } | |
| .ex-chip:hover { border-color: var(--accent); } | |
| .ex-chip .ex-label { font-size: 0.75rem; color: var(--text); font-weight: 550; } | |
| .ex-chip .ex-aspect { font-size: 0.62rem; color: var(--lavender); font-family: "IBM Plex Mono", ui-monospace, monospace; } | |
| #run-btn { | |
| margin-top: 4px; padding: 12px; border: 1px solid rgba(147,52,233,0.7); border-radius: 8px; cursor: pointer; | |
| background: var(--accent); color: white; box-shadow: inset 0 1px rgba(255,255,255,0.2); | |
| font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em; font-family: inherit; | |
| transition: filter 0.15s, transform 0.05s; | |
| } | |
| #run-btn:hover { filter: brightness(1.12); } | |
| #run-btn:active { transform: translateY(1px); } | |
| #run-btn:disabled { opacity: 0.5; cursor: wait; } | |
| .statusbar { | |
| display: flex; align-items: center; gap: 16px; padding: 7px 16px; flex-shrink: 0; | |
| background: var(--panel); border-top: 1px solid var(--hairline); | |
| font-size: 0.75rem; color: var(--muted); | |
| } | |
| .statusbar .pulse { width: 8px; height: 8px; border-radius: 50%; background: #4fd1a5; } | |
| .statusbar.busy .pulse { background: var(--accent2); animation: pulse 1s infinite alternate; } | |
| @keyframes pulse { from { opacity: 0.4; } to { opacity: 1; } } | |
| .foot-links { display: flex; gap: 12px; align-items: center; } | |
| .foot-links a { color: var(--dim); text-decoration: none; font-size: 0.72rem; font-weight: 500; } | |
| .foot-links a:hover { color: var(--lavender); } | |
| #file-input { display: none; } | |
| @media (max-width: 860px) { | |
| html, body { height: auto ; overflow: visible ; } | |
| body { display: block; } | |
| .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; } | |
| .brand { font-size: 0.88rem; } | |
| .topbar .ml-badge, .topbar .ml-badge-img { display: none; } | |
| .main { display: block; height: auto; min-height: 0; } | |
| .rail { | |
| flex-direction: row; width: 100%; justify-content: center; gap: 10px; | |
| padding: 6px 10px; border-right: none; border-bottom: 1px solid var(--hairline); | |
| } | |
| .rail button { width: 44px; height: 44px; } | |
| .viewport { display: block; padding: 10px; overflow: visible; } | |
| .workflow-view { position: static; height: 78vh; padding: 0 0 10px; } | |
| .doc-grid { flex-direction: column; align-items: stretch; height: auto; } | |
| .doc { max-width: 100%; width: 100%; } | |
| .doc .stage { min-height: 220px; } | |
| .panels { | |
| width: 100%; border-left: none; border-top: 1px solid var(--hairline); | |
| padding: 10px 12px; overflow-y: visible; | |
| } | |
| .mode-tabs button { padding: 6px 13px; font-size: 0.8rem; } | |
| .foot-links { display: none; } | |
| .statusbar { position: sticky; bottom: 0; } | |
| } | |
| /* DWD additions: split labels, timing bars, example thumbnails */ | |
| .doc figcaption .tag { | |
| margin-left: 8px; font-size: 0.58rem; letter-spacing: 0.08em; padding: 1px 7px; border-radius: 999px; | |
| border: 1px solid var(--border); color: var(--muted); text-transform: none; font-weight: 550; | |
| } | |
| .doc figcaption .tag.dwd { color: var(--lavender); background: var(--accent-soft); border-color: var(--accent); } | |
| .split-label { | |
| position: absolute; top: 10px; z-index: 6; font-size: 0.6rem; font-weight: 650; letter-spacing: 0.1em; | |
| text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,0.6); color: #eee; | |
| pointer-events: none; | |
| } | |
| .split-label.left { left: 10px; } | |
| .split-label.right { right: 10px; background: var(--accent); color: #fff; } | |
| .timing { display: flex; flex-direction: column; gap: 8px; } | |
| .timing .trow { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 0.72rem; color: var(--muted); } | |
| .timing .bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--raised); overflow: hidden; border: 1px solid var(--border); } | |
| .timing .bar span { display: block; height: 100%; border-radius: 999px; background: var(--dim); transition: width 0.4s; } | |
| .timing .trow.dwd .bar span { background: var(--accent); } | |
| .timing .trow b { color: var(--text); font-weight: 600; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.7rem; } | |
| .timing .speedup { font-size: 0.8rem; color: var(--lavender); font-weight: 650; } | |
| .ex-group { font-size: 0.6rem; font-weight: 650; letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; margin: 4px 0 0; } | |
| .ex-chip .ex-thumb { width: 34px; height: 34px; border-radius: 4px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); } | |
| .ex-chip .ex-left { display: flex; align-items: center; gap: 8px; min-width: 0; } | |
| .size-hint { font-size: 0.66rem; color: var(--dim); margin-top: 6px; } | |
| .size-hint.ok { color: var(--lavender); } | |
| </style> | |
| </head> | |
| <body> | |
| <header class="topbar"> | |
| <div class="brand"><img src="/pruna-logo.png" alt="Pruna" /><span id="brand-name"></span><span class="studio-badge">Studio</span></div> | |
| <div class="mode-tabs"> | |
| <button id="mode-generate" class="active">Generate</button> | |
| <button id="mode-edit">Edit</button> | |
| <button id="mode-workflow">Workflow</button> | |
| </div> | |
| <div class="spacer"></div> | |
| <a class="ml-badge" id="link-card" href="#" target="_blank" rel="noopener">Model card</a> | |
| <a class="ml-badge" id="link-comfy" href="#" target="_blank" rel="noopener">ComfyUI</a> | |
| <a class="ml-badge" href="https://arxiv.org/abs/2611.22287" target="_blank" rel="noopener">DWD paper</a> | |
| <a class="ml-badge" href="https://www.pruna.ai/" target="_blank" rel="noopener">pruna.ai</a> | |
| <button type="button" class="theme-toggle" id="theme-toggle" data-mode="dark" aria-label="Switch to light mode" title="Switch to light mode"> | |
| <svg class="theme-icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> | |
| <circle cx="12" cy="12" r="4"></circle> | |
| <path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"></path> | |
| </svg> | |
| <svg class="theme-icon-moon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> | |
| <path d="M21 14.5A8.5 8.5 0 1 1 9.5 3 7 7 0 0 0 21 14.5z"></path> | |
| </svg> | |
| </button> | |
| </header> | |
| <div class="main"> | |
| <div class="rail"> | |
| <button id="tool-upload" title="Upload an image to edit"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg></button> | |
| <button id="tool-clear-doc" title="Clear document"><svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg></button> | |
| </div> | |
| <div class="viewport"> | |
| <div class="workflow-view" id="workflow-view" hidden> | |
| <iframe data-src="/workflow/?ui=canvas" title="Workflow canvas"></iframe> | |
| </div> | |
| <div class="doc-grid"> | |
| <figure class="doc" id="doc-before"> | |
| <figcaption><span id="before-caption">Source</span></figcaption> | |
| <div class="stage" id="before-stage"> | |
| <img id="before-img" alt="" hidden /> | |
| <div class="drop-hint" id="before-hint"><b id="before-hint-title">No source image</b><span id="before-hint-text">Use the upload tool or drop a file here</span></div> | |
| </div> | |
| </figure> | |
| <figure class="doc" id="doc-after"> | |
| <figcaption>DWD head<span class="tag dwd">no VAE decode</span></figcaption> | |
| <div class="stage" id="after-stage"> | |
| <img id="result-img" alt="" hidden /> | |
| <div class="split-wrap" id="split-wrap" hidden> | |
| <img id="split-source" alt="" style="clip-path: inset(0 50% 0 0)" /> | |
| <div class="split-divider" id="split-divider" style="left:50%"></div> | |
| <span class="split-label left">Source</span> | |
| <span class="split-label right">DWD</span> | |
| </div> | |
| <div class="drop-hint" id="result-hint"><b>Nothing yet</b>Run to see the result</div> | |
| </div> | |
| <div class="doc-bar"> | |
| <span id="result-meta">—</span> | |
| <div class="spacer"></div> | |
| <button id="split-toggle" hidden>SPLIT</button> | |
| </div> | |
| </figure> | |
| </div> | |
| <div class="history-strip" id="history-strip"><span class="hlabel">History</span></div> | |
| </div> | |
| <aside class="panels"> | |
| <section class="panel"> | |
| <div class="panel-title">Examples</div> | |
| <div id="examples"></div> | |
| </section> | |
| <section class="panel"> | |
| <div class="panel-title" id="prompt-title">Prompt</div> | |
| <textarea id="prompt" rows="5" placeholder="Describe the image…"></textarea> | |
| </section> | |
| <section class="panel"> | |
| <div class="panel-title">Composition</div> | |
| <div id="aspect-row"> | |
| <label for="aspect">Aspect ratio</label> | |
| <select id="aspect"></select> | |
| </div> | |
| <div id="resolution-row"> | |
| <label for="resolution">Resolution</label> | |
| <select id="resolution"></select> | |
| </div> | |
| <div class="size-hint" id="size-hint"></div> | |
| </section> | |
| <section class="panel" id="layers-panel" hidden> | |
| <div class="panel-title">Condition images</div> | |
| <div class="layer-row" id="layer-source"> | |
| <div class="thumb" id="layer-source-thumb">SRC</div> | |
| <div class="lname">Source<span class="lsub">this one is edited; the output keeps its aspect ratio</span></div> | |
| </div> | |
| <div class="ref-grid"> | |
| <div class="ref-slot" data-ref="2">+ Image 2</div> | |
| <div class="ref-slot" data-ref="3">+ Image 3</div> | |
| <div class="ref-slot" data-ref="4">+ Image 4</div> | |
| </div> | |
| <div class="hint">Extra images are passed to the model as further condition images, in order.</div> | |
| </section> | |
| <section class="panel"> | |
| <div class="panel-title">Advanced</div> | |
| <div class="row"> | |
| <div><label for="seed">Seed</label><input type="number" id="seed" value="42" min="0" /></div> | |
| <label class="switch"><input type="checkbox" id="randomize" checked /><span class="sw"></span><span class="sw-label">Randomize</span></label> | |
| </div> | |
| </section> | |
| <section class="panel"> | |
| <div class="panel-title">Timing</div> | |
| <div class="timing" id="timing"></div> | |
| </section> | |
| <button id="run-btn">Generate</button> | |
| </aside> | |
| </div> | |
| <footer class="statusbar" id="statusbar"> | |
| <div class="pulse"></div> | |
| <span id="status">Idle</span> | |
| <div class="spacer"></div> | |
| <span class="foot-links"> | |
| <a href="https://github.com/PrunaAI/pruna" target="_blank" rel="noopener">GitHub</a> | |
| <a href="https://discord.gg/JFQmtFKCjd" target="_blank" rel="noopener">Discord</a> | |
| <a href="https://x.com/PrunaAI" target="_blank" rel="noopener">X</a> | |
| </span> | |
| <span id="seed-out"></span> | |
| </footer> | |
| <input type="file" id="file-input" accept="image/*" /> | |
| <script type="module"> | |
| import { client } from "https://cdn.jsdelivr.net/npm/@gradio/client@2.7.1/dist/index.min.js"; | |
| // Filled in by app.py: name, links, base model name, whether editing is supported, examples, sizes, timing labels. | |
| const CONFIG = __STUDIO_CONFIG__; | |
| const $ = (id) => document.getElementById(id); | |
| const state = { mode: "generate", sourcePath: null, sourceUri: null, refPaths: { 2: null, 3: null, 4: null }, app: null }; | |
| const docState = { result: null, history: [] }; | |
| function el(tag, cls, text) { | |
| const node = document.createElement(tag); | |
| if (cls) node.className = cls; | |
| if (text != null) node.textContent = text; | |
| return node; | |
| } | |
| // ---------- static config ---------- | |
| $("brand-name").textContent = CONFIG.name; | |
| document.title = CONFIG.name + " Studio"; | |
| $("link-card").href = CONFIG.modelCard; | |
| $("link-comfy").href = CONFIG.comfy; | |
| if (!CONFIG.edit) { | |
| $("mode-edit").remove(); | |
| $("tool-upload").remove(); | |
| } | |
| async function getApp() { | |
| if (!state.app) state.app = await client(location.origin); | |
| return state.app; | |
| } | |
| async function uploadFile(file) { | |
| const form = new FormData(); | |
| form.append("files", file); | |
| const resp = await fetch("/gradio_api/upload", { method: "POST", body: form }); | |
| if (!resp.ok) throw new Error(`Upload failed (${resp.status})`); | |
| const paths = await resp.json(); | |
| return Array.isArray(paths) ? paths[0] : paths; | |
| } | |
| function setStatus(text, busy = false) { | |
| $("status").textContent = text; | |
| $("statusbar").classList.toggle("busy", busy); | |
| $("run-btn").disabled = busy; | |
| } | |
| // ---------- theme ---------- | |
| const themeBtn = $("theme-toggle"); | |
| function applyTheme(mode) { | |
| document.body.classList.toggle("light", mode === "light"); | |
| themeBtn.dataset.mode = mode; | |
| const label = mode === "dark" ? "Switch to light mode" : "Switch to dark mode"; | |
| themeBtn.setAttribute("aria-label", label); | |
| themeBtn.setAttribute("title", label); | |
| try { localStorage.setItem("pruna-theme", mode); } catch (e) {} | |
| } | |
| themeBtn.onclick = () => applyTheme(document.body.classList.contains("light") ? "dark" : "light"); | |
| (function initTheme() { | |
| let mode = "dark"; | |
| try { if (localStorage.getItem("pruna-theme") === "light") mode = "light"; } catch (e) {} | |
| applyTheme(mode); | |
| })(); | |
| // ---------- composition ---------- | |
| function fillSelect(sel, list, preferred) { | |
| const prev = sel.value; | |
| sel.replaceChildren(...list.map((v) => { const o = el("option", null, v); o.value = v; return o; })); | |
| sel.value = list.includes(prev) ? prev : preferred; | |
| } | |
| fillSelect($("aspect"), CONFIG.ratios, CONFIG.ratios[0]); | |
| fillSelect($("resolution"), CONFIG.resolutions, CONFIG.defaultResolution); | |
| function updateSizeHint() { | |
| const hint = $("size-hint"); | |
| if (state.mode === "edit") { | |
| hint.className = "size-hint"; | |
| hint.textContent = "The output keeps the source's aspect ratio at this area."; | |
| return; | |
| } | |
| const size = (CONFIG.evaluated[$("resolution").value] || {})[$("aspect").value]; | |
| hint.className = size ? "size-hint ok" : "size-hint"; | |
| hint.textContent = size | |
| ? `${size[0]} × ${size[1]} · a size the model was evaluated at` | |
| : "Same area at this ratio; not one of the evaluated sizes."; | |
| } | |
| $("aspect").onchange = updateSizeHint; | |
| $("resolution").onchange = updateSizeHint; | |
| // ---------- documents ---------- | |
| function showBefore() { | |
| // Edit mode only: the source image. Generate mode shows the DWD result alone. | |
| const edit = state.mode === "edit"; | |
| const uri = edit ? state.sourceUri : null; | |
| const img = $("before-img"); | |
| if (uri) { | |
| img.src = uri; | |
| img.hidden = false; | |
| $("before-hint").style.display = "none"; | |
| } else { | |
| img.hidden = true; | |
| $("before-hint").style.display = ""; | |
| $("before-hint-text").textContent = "Use the upload tool, drop a file here or pick an example"; | |
| } | |
| $("doc-before").style.display = edit ? "" : "none"; | |
| updateSplit(); | |
| } | |
| function splitPartner() { | |
| return state.mode === "edit" ? state.sourceUri : null; | |
| } | |
| function updateSplit() { | |
| const partner = splitPartner(); | |
| const can = !$("result-img").hidden && !!partner; | |
| $("split-toggle").hidden = !can; | |
| if (!can && splitOn) toggleSplit(false); | |
| if (splitOn && partner) $("split-source").src = partner; | |
| } | |
| function setMode(mode) { | |
| state.mode = mode; | |
| for (const m of ["generate", "edit", "workflow"]) $(`mode-${m}`)?.classList.toggle("active", mode === m); | |
| const workflow = mode === "workflow"; | |
| $("workflow-view").hidden = !workflow; | |
| const frame = $("workflow-view").querySelector("iframe"); | |
| if (workflow && !frame.getAttribute("src")) frame.src = frame.dataset.src; | |
| document.querySelector(".doc-grid").style.display = workflow ? "none" : ""; | |
| document.querySelector(".rail").style.display = workflow ? "none" : ""; | |
| document.querySelector(".panels").style.display = workflow ? "none" : ""; | |
| $("history-strip").style.display = workflow ? "none" : ""; | |
| if (workflow) return; | |
| const edit = mode === "edit"; | |
| const resolutions = edit ? CONFIG.editResolutions : CONFIG.resolutions; | |
| $("layers-panel").hidden = !edit; | |
| $("aspect-row").style.display = edit ? "none" : ""; | |
| fillSelect($("resolution"), resolutions, edit ? resolutions[0] : CONFIG.defaultResolution); | |
| $("resolution-row").style.display = resolutions.length < 2 ? "none" : ""; | |
| $("run-btn").textContent = edit ? "Generate Edit" : "Generate"; | |
| $("prompt-title").textContent = edit ? "Edit instruction" : "Prompt"; | |
| $("prompt").placeholder = edit ? "e.g. Add gently falling snow to the whole scene." : "Describe the image…"; | |
| updateSizeHint(); | |
| showBefore(); | |
| } | |
| $("mode-generate").onclick = () => setMode("generate"); | |
| if ($("mode-edit")) $("mode-edit").onclick = () => setMode("edit"); | |
| $("mode-workflow").onclick = () => setMode("workflow"); | |
| // ---------- uploads ---------- | |
| let uploadTarget = "source"; | |
| function pickFile(target) { | |
| uploadTarget = target; | |
| $("file-input").click(); | |
| } | |
| if ($("tool-upload")) $("tool-upload").onclick = () => { setMode("edit"); pickFile("source"); }; | |
| document.querySelectorAll(".ref-slot").forEach((slot) => { slot.onclick = () => pickFile(slot.dataset.ref); }); | |
| $("file-input").onchange = async (e) => { | |
| const file = e.target.files[0]; | |
| e.target.value = ""; | |
| if (!file) return; | |
| setStatus("Uploading…", true); | |
| try { | |
| const path = await uploadFile(file); | |
| if (uploadTarget === "source") { | |
| setSource(path, URL.createObjectURL(file)); | |
| } else { | |
| state.refPaths[uploadTarget] = path; | |
| const slot = document.querySelector(`.ref-slot[data-ref="${uploadTarget}"]`); | |
| const img = el("img"); | |
| img.src = URL.createObjectURL(file); | |
| slot.replaceChildren(img); | |
| } | |
| setStatus("Idle"); | |
| } catch (err) { | |
| setStatus(String(err)); | |
| } | |
| }; | |
| $("before-stage").addEventListener("dragover", (e) => e.preventDefault()); | |
| $("before-stage").addEventListener("drop", async (e) => { | |
| e.preventDefault(); | |
| if (!CONFIG.edit) return; | |
| const file = e.dataTransfer.files[0]; | |
| if (!file) return; | |
| setStatus("Uploading…", true); | |
| try { | |
| setSource(await uploadFile(file), URL.createObjectURL(file)); | |
| setStatus("Idle"); | |
| } catch (err) { | |
| setStatus(String(err)); | |
| } | |
| }); | |
| function setSource(path, uri) { | |
| state.sourcePath = path; | |
| state.sourceUri = uri; | |
| const img = el("img"); | |
| img.src = uri; | |
| $("layer-source-thumb").replaceChildren(img); | |
| setMode("edit"); | |
| } | |
| function clearResult() { | |
| docState.result = null; | |
| $("result-img").hidden = true; | |
| $("result-hint").style.display = ""; | |
| $("result-meta").textContent = "—"; | |
| $("seed-out").textContent = ""; | |
| renderTiming(null); | |
| } | |
| $("tool-clear-doc").onclick = () => { | |
| state.sourcePath = null; | |
| state.sourceUri = null; | |
| for (const k of Object.keys(state.refPaths)) state.refPaths[k] = null; | |
| clearResult(); | |
| $("layer-source-thumb").textContent = "SRC"; | |
| document.querySelectorAll(".ref-slot").forEach((slot) => { slot.textContent = `+ Image ${slot.dataset.ref}`; }); | |
| showBefore(); | |
| }; | |
| // ---------- timing ---------- | |
| function timingRow(cls, label, ms, max) { | |
| const row = el("div", "trow " + cls); | |
| const bar = el("div", "bar"); | |
| const fill = el("span"); | |
| fill.style.width = Math.max(3, (100 * ms) / max).toFixed(1) + "%"; | |
| bar.appendChild(fill); | |
| row.append(el("span", null, label), el("b", null, `${ms.toLocaleString()} ms`), bar); | |
| return row; | |
| } | |
| function renderTiming(t) { | |
| const box = $("timing"); | |
| const hint = (text) => { const h = el("div", "hint", text); h.style.marginTop = "0"; return h; }; | |
| if (!t) { box.replaceChildren(hint("Filled in after a run.")); return; } | |
| const nodes = []; | |
| const total = t.dwd + (t.shared || 0); | |
| if (t.shared != null) nodes.push(timingRow("", CONFIG.sharedLabel, t.shared, total)); | |
| nodes.push(timingRow("dwd", CONFIG.dwdLabel, t.dwd, total)); | |
| nodes.push(el("div", "speedup", `${total.toLocaleString()} ms on the GPU, no VAE decode`)); | |
| nodes.push(hint("Measured on this run, on a shared ZeroGPU slot; the model card has the controlled benchmark.")); | |
| box.replaceChildren(...nodes); | |
| } | |
| renderTiming(null); | |
| // ---------- history ---------- | |
| function renderHistory() { | |
| const strip = $("history-strip"); | |
| strip.replaceChildren(el("span", "hlabel", "History")); | |
| docState.history.forEach((h) => { | |
| const chip = el("div", "history-chip"); | |
| chip.title = h.prompt || ""; | |
| const img = el("img"); | |
| img.src = h.uri; | |
| chip.append(img, el("div", "hseed", h.seed ?? "")); | |
| chip.onclick = () => { | |
| if (h.mode === "edit" && h.sourcePath) { state.sourcePath = h.sourcePath; state.sourceUri = h.sourceUri; } | |
| $("prompt").value = h.prompt; | |
| $("seed").value = h.seed ?? 42; | |
| $("randomize").checked = false; | |
| if (h.aspect) $("aspect").value = h.aspect; | |
| setMode(h.mode || "generate"); | |
| if (h.resolution) $("resolution").value = h.resolution; | |
| updateSizeHint(); | |
| showImages(h.uri); | |
| $("result-meta").textContent = h.info || ""; | |
| renderTiming(h.timing); | |
| }; | |
| strip.appendChild(chip); | |
| }); | |
| } | |
| function pushHistory(entry) { | |
| docState.history.unshift(entry); | |
| if (docState.history.length > 10) docState.history.pop(); | |
| renderHistory(); | |
| } | |
| // ---------- before/after split view ---------- | |
| let splitOn = false; | |
| function toggleSplit(on) { | |
| splitOn = on; | |
| $("split-toggle").classList.toggle("active", splitOn); | |
| $("split-wrap").hidden = !splitOn; | |
| const partner = splitPartner(); | |
| if (splitOn && partner) $("split-source").src = partner; | |
| } | |
| $("split-toggle").onclick = () => { if (!$("result-img").hidden) toggleSplit(!splitOn); }; | |
| (function () { | |
| const divider = $("split-divider"); | |
| let dragging = false; | |
| divider.addEventListener("pointerdown", (e) => { dragging = true; e.preventDefault(); }); | |
| window.addEventListener("pointermove", (e) => { | |
| if (!dragging) return; | |
| const stage = $("after-stage").getBoundingClientRect(); | |
| const pct = Math.min(97, Math.max(3, ((e.clientX - stage.left) / stage.width) * 100)); | |
| divider.style.left = pct + "%"; | |
| $("split-source").style.clipPath = `inset(0 ${100 - pct}% 0 0)`; | |
| }); | |
| window.addEventListener("pointerup", () => { dragging = false; }); | |
| })(); | |
| // ---------- zoom ---------- | |
| document.querySelectorAll(".doc figcaption").forEach((caption) => { | |
| const btn = el("button", "zoom-btn", "FIT"); | |
| btn.onclick = () => { | |
| const fig = caption.parentElement; | |
| const stage = fig.querySelector(".stage"); | |
| const zoomed = !stage.classList.contains("scrollable"); | |
| fig.querySelectorAll(".stage > img").forEach((img) => img.classList.toggle("zoomed", zoomed)); | |
| stage.classList.toggle("scrollable", zoomed); | |
| btn.textContent = zoomed ? "1:1" : "FIT"; | |
| }; | |
| caption.appendChild(btn); | |
| }); | |
| // ---------- collapsible panels ---------- | |
| document.querySelectorAll(".panel .panel-title").forEach((title) => { | |
| const body = el("div", "panel-body"); | |
| [...title.parentElement.children].forEach((child) => { if (child !== title) body.appendChild(child); }); | |
| title.parentElement.appendChild(body); | |
| title.onclick = () => title.parentElement.classList.toggle("collapsed"); | |
| }); | |
| // ---------- examples ---------- | |
| const exRow = $("examples"); | |
| function exChip(label, right, thumb) { | |
| const chip = el("button", "ex-chip"); | |
| const left = el("span", "ex-left"); | |
| if (thumb) { | |
| const img = el("img", "ex-thumb"); | |
| img.src = thumb; | |
| img.loading = "lazy"; | |
| left.appendChild(img); | |
| } | |
| left.appendChild(el("span", "ex-label", label)); | |
| chip.append(left, el("span", "ex-aspect", right)); | |
| exRow.appendChild(chip); | |
| return chip; | |
| } | |
| const editExamples = CONFIG.edit ? (CONFIG.examples.edit || []) : []; | |
| if (editExamples.length) exRow.appendChild(el("div", "ex-group", "Text-to-image")); | |
| (CONFIG.examples.generate || []).forEach((ex) => { | |
| const right = ex.resolution && CONFIG.resolutions.length > 1 ? `${ex.aspect} · ${ex.resolution}` : ex.aspect; | |
| exChip(ex.label, right).onclick = () => { | |
| setMode("generate"); | |
| $("prompt").value = ex.prompt; | |
| $("aspect").value = ex.aspect; | |
| if (ex.resolution) $("resolution").value = ex.resolution; | |
| $("seed").value = ex.seed ?? 0; | |
| $("randomize").checked = false; | |
| updateSizeHint(); | |
| setStatus("Example loaded (the model card's prompt and seed) — hit Generate"); | |
| }; | |
| }); | |
| if (editExamples.length) exRow.appendChild(el("div", "ex-group", "Image editing")); | |
| editExamples.forEach((ex) => { | |
| exChip(ex.label, "edit", `/examples/${ex.file}`).onclick = async () => { | |
| setStatus("Loading example…", true); | |
| try { | |
| const blob = await (await fetch(`/examples/${ex.file}`)).blob(); | |
| const file = new File([blob], ex.file, { type: blob.type || "image/jpeg" }); | |
| const path = await uploadFile(file); | |
| clearResult(); | |
| setSource(path, URL.createObjectURL(file)); | |
| $("prompt").value = ex.instruction; | |
| $("seed").value = ex.seed ?? 0; | |
| $("randomize").checked = false; | |
| setStatus("Example loaded (the model card's input, instruction and seed) — hit Generate Edit"); | |
| } catch (err) { | |
| setStatus(String(err)); | |
| } | |
| }; | |
| }); | |
| // ---------- result handling ---------- | |
| function unwrap(result) { | |
| const data = Array.isArray(result?.data) ? result.data[0] : result?.data; | |
| return data ?? {}; | |
| } | |
| function showImages(uri) { | |
| docState.result = uri; | |
| const img = $("result-img"); | |
| img.src = uri; | |
| img.hidden = false; | |
| $("result-hint").style.display = "none"; | |
| showBefore(); | |
| } | |
| function showResult(result) { | |
| const payload = unwrap(result); | |
| const url = typeof payload.image_data === "string" ? payload.image_data : null; | |
| if (!url) { setStatus("Run finished but no image came back (see console)."); return false; } | |
| showImages(url); | |
| if (payload.seed != null) $("seed-out").textContent = "seed " + payload.seed; | |
| $("result-meta").textContent = payload.info || "Done"; | |
| renderTiming(payload.timing_ms); | |
| pushHistory({ | |
| uri: url, seed: payload.seed, prompt: $("prompt").value.trim(), mode: state.mode, | |
| aspect: $("aspect").value, resolution: $("resolution").value, info: payload.info, timing: payload.timing_ms, | |
| sourcePath: state.sourcePath, sourceUri: state.sourceUri, | |
| }); | |
| return true; | |
| } | |
| $("run-btn").onclick = async () => { | |
| const prompt = $("prompt").value.trim(); | |
| const seed = parseInt($("seed").value, 10) || 0; | |
| const randomize = $("randomize").checked; | |
| const resolution = $("resolution").value; | |
| try { | |
| let result; | |
| if (state.mode === "edit") { | |
| if (!state.sourcePath) { setStatus("Upload a source image first."); return; } | |
| if (!prompt) { setStatus("Describe the edit first."); return; } | |
| setStatus("Editing…", true); | |
| const app = await getApp(); | |
| result = await app.predict("/edit", { | |
| source: state.sourcePath, instruction: prompt, | |
| ref2: state.refPaths[2], ref3: state.refPaths[3], ref4: state.refPaths[4], | |
| resolution, seed, randomize, | |
| }); | |
| } else { | |
| if (!prompt) { setStatus("Write a prompt first."); return; } | |
| setStatus("Rendering…", true); | |
| const app = await getApp(); | |
| const args = { prompt, aspect: $("aspect").value, seed, randomize }; | |
| if (CONFIG.resolutions.length > 1) args.resolution = resolution; | |
| result = await app.predict("/generate", args); | |
| } | |
| if (showResult(result)) setStatus("Done"); | |
| } catch (err) { | |
| setStatus(err?.message || String(err)); | |
| } | |
| }; | |
| setMode("generate"); | |
| </script> | |
| </body> | |
| </html> | |