Spaces:
Running
Running
Seeds match dflow/ComfyUI (torch.randn port); LoRA card example link; compact settings
Browse filesFiles changed (3)
- app.js+44-14
- index.html+3-1
- style.css+1
126 unmodified lines127128129130131132133134135136137138139140141142143144145146147148331 unmodified lines480481482483484485126 unmodified lines}// ---------- noise ----------function gaussianNoise(count, seed) {let s = (seed >>> 0) || 1;const next = () => { // mulberry32s = (s + 0x6d2b79f5) >>> 0;let t = s;t = Math.imul(t ^ (t >>> 15), t | 1);t ^= t + Math.imul(t ^ (t >>> 7), t | 61);return ((t ^ (t >>> 14)) >>> 0) / 4294967296;};const out = new Float32Array(count);for (let i = 0; i < count; i += 2) {const u = Math.max(next(), 1e-12), v = next(), r = Math.sqrt(-2 * Math.log(u));out[i] = r * Math.cos(2 * Math.PI * v);if (i + 1 < count) out[i + 1] = r * Math.sin(2 * Math.PI * v);}return out;}// ---------- downloads ----------331 unmodified linesui.random.addEventListener('change', () => { ui.seed.disabled = ui.random.checked; });ui.seed.disabled = ui.random.checked;ui.save.addEventListener('click', (e) => { if (ui.save.classList.contains('disabled')) e.preventDefault(); });try { // drop files of older page versionsfor (const k of await caches.keys()) if (k.startsWith('dflow2-web-') && k !== CACHE) await caches.delete(k);} catch { /* no Cache API */ }126 unmodified lines127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169331 unmodified lines501502503504505506507508509510511512513514515126 unmodified lines}// ---------- noise ----------// Same numbers as torch.randn(shape, generator=torch.Generator('cpu').manual_seed(seed)), which// is how dflow draws its starting noise: mt19937, uniforms u = (r & 0xFFFFFF) / 2^24, then// Box-Muller over blocks of 16 (ATen normal_fill). So a seed here gives the same picture as the// same seed in dflow, ComfyUI or the LoRA card (within float rounding).function mt19937(seed) {const mt = new Uint32Array(624);mt[0] = seed >>> 0;for (let i = 1; i < 624; i++) mt[i] = (Math.imul(1812433253, mt[i - 1] ^ (mt[i - 1] >>> 30)) + i) >>> 0;let idx = 624;return () => {if (idx >= 624) {for (let i = 0; i < 624; i++) {const y = (mt[i] & 0x80000000) | (mt[(i + 1) % 624] & 0x7fffffff);mt[i] = mt[(i + 397) % 624] ^ (y >>> 1) ^ (y & 1 ? 0x9908b0df : 0);}idx = 0;}let y = mt[idx++];y ^= y >>> 11; y ^= (y << 7) & 0x9d2c5680; y ^= (y << 15) & 0xefc60000; y ^= y >>> 18;return y >>> 0;};}function gaussianNoise(count, seed) {const next = mt19937(seed), d = new Float32Array(count);const uniform = () => (next() & 0xffffff) / 16777216;for (let i = 0; i < count; i++) d[i] = uniform();const fill16 = (o) => {for (let j = 0; j < 8; j++) {const r = fr(Math.sqrt(fr(-2 * fr(Math.log(fr(1 - d[o + j]))))));const th = fr(2 * Math.PI * d[o + j + 8]);d[o + j] = fr(r * fr(Math.cos(th))); d[o + j + 8] = fr(r * fr(Math.sin(th)));}};for (let o = 0; o + 16 <= count; o += 16) fill16(o);if (count % 16) { const o = count - 16; for (let j = 0; j < 16; j++) d[o + j] = uniform(); fill16(o); }return d;}// ---------- downloads ----------331 unmodified linesui.random.addEventListener('change', () => { ui.seed.disabled = ui.random.checked; });ui.seed.disabled = ui.random.checked;ui.save.addEventListener('click', (e) => { if (ui.save.classList.contains('disabled')) e.preventDefault(); });$('example').addEventListener('click', (e) => { // the LoRA card's snow leopard: same prompt, seed, sizee.preventDefault();ui.prompt.value = 'A snow leopard walking along a rocky ridge in falling snow, telephoto wildlife photograph, natural light';ui.random.checked = false; ui.seed.disabled = false; ui.seed.value = 4242;const card = [...ui.size.options].some((o) => o.value === '1824x1024');if (card) ui.size.value = '1824x1024';status(card ? 'Card example loaded. Generate, then compare with the card image.': 'Card example loaded, but this GPU cannot do 1824×1024, so the result will differ from the card image.', null, !card);});try { // drop files of older page versionsfor (const k of await caches.keys()) if (k.startsWith('dflow2-web-') && k !== CACHE) await caches.delete(k);} catch { /* no Cache API */ }
16 unmodified lines1718192021222316 unmodified lines<section id="input"><label for="prompt" class="sr">Prompt</label><textarea id="prompt" rows="7" spellcheck="false">A snow leopard walking along a rocky ridge in falling snow, telephoto wildlife photograph, natural light</textarea><p class="hint">Describe a photo or a painting: subject, setting, light, medium. Text in "double quotes" is spelled letter by letter. Detail grows with size: the model was trained at about 1 MP, 512² is a quick preview.</p></section><section id="settings">16 unmodified lines17181920212223242516 unmodified lines<section id="input"><label for="prompt" class="sr">Prompt</label><textarea id="prompt" rows="7" spellcheck="false">A snow leopard walking along a rocky ridge in falling snow, telephoto wildlife photograph, natural light</textarea><p class="hint">Describe subject, setting, light and medium; "quoted text" is spelled letter by letter. Trained at about 1 MP, so 512² is only a preview.Seeds match dflow: <a href="#" id="example">load the LoRA card example</a> (seed 4242, 1824×1024) and compare with<a href="https://huggingface.co/lvladikov/DFlow2-Distill-4steps-eDMD-LADD-LoRA/blob/main/assets/images/snowleopard.jpg" target="_blank" rel="noopener">the card image</a>.</p></section><section id="settings">
37 unmodified lines38394041424337 unmodified lines}.hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); }@media (max-height: 480px) { .hint { display: none; } #line { font-size: 13px; } }label { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }select, input[type=number] {font: inherit; min-height: 30px; padding: 2px 6px; color: var(--ink); background: var(--panel);37 unmodified lines3839404142434437 unmodified lines}.hint { margin: 2px 0 0; font-size: 12px; color: var(--muted); }@media (max-height: 480px) { .hint { display: none; } #line { font-size: 13px; } }@media (max-width: 599px) { textarea { height: calc(5 * 1.4em + 14px); max-height: calc(5 * 1.4em + 14px); } }label { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }select, input[type=number] {font: inherit; min-height: 30px; padding: 2px 6px; color: var(--ink); background: var(--panel);
app.js+44-14
index.html+3-1
style.css+1