Frontend: restore LoRA stack (3 slots) in custom UI
Browse files- static/index.html +51 -2
static/index.html
CHANGED
|
@@ -206,6 +206,10 @@ select.input{min-height:30px;padding:4px 8px;font-size:12px;width:auto}
|
|
| 206 |
.fold > summary .chev{margin-left:auto;color:var(--color-muted);transition:transform .2s var(--ease)}
|
| 207 |
.fold[open] > summary .chev{transform:rotate(180deg)}
|
| 208 |
.fold-body{display:flex;flex-direction:column;gap:14px;padding:4px 14px 16px}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
.fold.on{box-shadow:0 0 0 1px color-mix(in srgb,var(--color-accent) 60%,transparent)}
|
| 210 |
|
| 211 |
.warn{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px;padding:10px 12px;border-radius:var(--radius-md);background:var(--color-warn-tint);font-size:12.5px;color:var(--color-text)}
|
|
@@ -477,6 +481,15 @@ button.chip:hover{background:color-mix(in srgb,var(--color-text) 12%,transparent
|
|
| 477 |
</div>
|
| 478 |
</details>
|
| 479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 480 |
<!-- Control -->
|
| 481 |
<details class="fold" id="cnFold">
|
| 482 |
<summary><span>Control</span><span class="sub">Pose · lineart · inpaint</span><span class="tag tag-neutral" id="cnTag" style="margin-left:auto">Off</span><i class="ph ph-caret-down chev" style="margin-left:0"></i></summary>
|
|
@@ -759,7 +772,8 @@ function defaults(){
|
|
| 759 |
return { prompt: d.prompt, negative: d.negative_prompt ?? d.negative, prefix: d.add_recommended_prefix ?? true, model: CFG.default_diffusion,
|
| 760 |
width: d.width, height: d.height, ratio:'1:1', steps: d.steps, cfg: d.cfg_scale, shift: d.sigma_shift, seed: d.seed ?? -1,
|
| 761 |
ctl:'Off', ctlStrength:1, ctlStart:0, ctlEnd:1,
|
| 762 |
-
poseSource: SRC.det, poseJson:'', poseHands: !!d.pose_hands, poseFace: !!d.pose_face, poseFeet: !!d.pose_feet, poseFit: d.pose_fit || 'contain', poseStyle: CFG.pose_default_style || 'R0_thin', poseMax: d.pose_max_people || 1
|
|
|
|
| 763 |
}
|
| 764 |
const AREA = () => 1408 * 1408;
|
| 765 |
function dimsFor(rw, rh, area = AREA()){
|
|
@@ -848,9 +862,44 @@ function sync(){
|
|
| 848 |
$('#seed').value = P.seed < 0 ? '' : String(P.seed);
|
| 849 |
$('#seedPin').disabled = S.lastSeed == null;
|
| 850 |
$('#turboNote').hidden = !isTurbo(P.model);
|
|
|
|
| 851 |
syncCtl();
|
| 852 |
if (!S.busy) setFrameRatio(P.width / P.height);
|
| 853 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
function syncCtl(){
|
| 855 |
const mid = modeId(P.ctl), ui = MODE_UI[mid], d = cdef(P.ctl);
|
| 856 |
document.querySelectorAll('#modes button').forEach(b => { const on = b.dataset.m === P.ctl; b.setAttribute('aria-checked', on); b.tabIndex = on ? 0 : -1; });
|
|
@@ -1429,7 +1478,7 @@ async function generate(){
|
|
| 1429 |
job = client.submit('/generate', [P.prompt, P.negative, P.prefix, P.model, P.width, P.height, P.steps, +P.cfg, +P.shift, P.seed,
|
| 1430 |
P.ctl, img, mask, +P.ctlStrength, +P.ctlStart, +P.ctlEnd,
|
| 1431 |
P.poseSource, mid === 'pose' ? (P.poseJson || '') : '', P.poseHands, P.poseFace, P.poseFeet, P.poseFit, P.poseStyle, P.poseMax,
|
| 1432 |
-
|
| 1433 |
}
|
| 1434 |
S.job = job;
|
| 1435 |
for await (const m of job){
|
|
|
|
| 206 |
.fold > summary .chev{margin-left:auto;color:var(--color-muted);transition:transform .2s var(--ease)}
|
| 207 |
.fold[open] > summary .chev{transform:rotate(180deg)}
|
| 208 |
.fold-body{display:flex;flex-direction:column;gap:14px;padding:4px 14px 16px}
|
| 209 |
+
.lora-row{display:grid;grid-template-columns:20px minmax(0,1fr) 64px;align-items:center;gap:8px}
|
| 210 |
+
.lora-row .ix{font-family:var(--font-mono);font-size:11px;color:var(--color-faint);text-align:center}
|
| 211 |
+
.lora-row .input{font-size:12px;font-family:var(--font-mono)}
|
| 212 |
+
.lora-row.on .ix{color:var(--color-accent)}
|
| 213 |
.fold.on{box-shadow:0 0 0 1px color-mix(in srgb,var(--color-accent) 60%,transparent)}
|
| 214 |
|
| 215 |
.warn{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px;padding:10px 12px;border-radius:var(--radius-md);background:var(--color-warn-tint);font-size:12.5px;color:var(--color-text)}
|
|
|
|
| 481 |
</div>
|
| 482 |
</details>
|
| 483 |
|
| 484 |
+
<!-- LoRA stack -->
|
| 485 |
+
<details class="fold" id="loraFold">
|
| 486 |
+
<summary><span>LoRA</span><span class="sub">Up to 3 · HF / Civitai / URL</span><span class="tag tag-neutral" id="loraTag" style="margin-left:auto">Off</span><i class="ph ph-caret-down chev" style="margin-left:0"></i></summary>
|
| 487 |
+
<div class="fold-body">
|
| 488 |
+
<div id="loraRows" style="display:flex;flex-direction:column;gap:8px"></div>
|
| 489 |
+
<span class="mask-hint">HF repo (<span class="mono">user/repo</span> or <span class="mono">user/repo/file.safetensors</span>), Civitai model link or a direct .safetensors URL. Weight 0–2; empty slot = off.</span>
|
| 490 |
+
</div>
|
| 491 |
+
</details>
|
| 492 |
+
|
| 493 |
<!-- Control -->
|
| 494 |
<details class="fold" id="cnFold">
|
| 495 |
<summary><span>Control</span><span class="sub">Pose · lineart · inpaint</span><span class="tag tag-neutral" id="cnTag" style="margin-left:auto">Off</span><i class="ph ph-caret-down chev" style="margin-left:0"></i></summary>
|
|
|
|
| 772 |
return { prompt: d.prompt, negative: d.negative_prompt ?? d.negative, prefix: d.add_recommended_prefix ?? true, model: CFG.default_diffusion,
|
| 773 |
width: d.width, height: d.height, ratio:'1:1', steps: d.steps, cfg: d.cfg_scale, shift: d.sigma_shift, seed: d.seed ?? -1,
|
| 774 |
ctl:'Off', ctlStrength:1, ctlStart:0, ctlEnd:1,
|
| 775 |
+
poseSource: SRC.det, poseJson:'', poseHands: !!d.pose_hands, poseFace: !!d.pose_face, poseFeet: !!d.pose_feet, poseFit: d.pose_fit || 'contain', poseStyle: CFG.pose_default_style || 'R0_thin', poseMax: d.pose_max_people || 1,
|
| 776 |
+
loras: [{ url:'', w:1 }, { url:'', w:1 }, { url:'', w:1 }] };
|
| 777 |
}
|
| 778 |
const AREA = () => 1408 * 1408;
|
| 779 |
function dimsFor(rw, rh, area = AREA()){
|
|
|
|
| 862 |
$('#seed').value = P.seed < 0 ? '' : String(P.seed);
|
| 863 |
$('#seedPin').disabled = S.lastSeed == null;
|
| 864 |
$('#turboNote').hidden = !isTurbo(P.model);
|
| 865 |
+
syncLora();
|
| 866 |
syncCtl();
|
| 867 |
if (!S.busy) setFrameRatio(P.width / P.height);
|
| 868 |
}
|
| 869 |
+
function normLoras(){
|
| 870 |
+
const l = Array.isArray(P.loras) ? P.loras : [];
|
| 871 |
+
P.loras = [0,1,2].map(i => ({ url: String((l[i] && l[i].url) || ''), w: Number.isFinite(+(l[i] && l[i].w)) ? +l[i].w : 1 }));
|
| 872 |
+
}
|
| 873 |
+
function syncLora(){
|
| 874 |
+
normLoras();
|
| 875 |
+
const box = $('#loraRows');
|
| 876 |
+
if (!box.children.length){
|
| 877 |
+
box.innerHTML = [0,1,2].map(i => `<div class="lora-row" data-i="${i}"><span class="ix">${i+1}</span>`
|
| 878 |
+
+ `<input class="input" type="text" spellcheck="false" autocomplete="off" placeholder="LoRA ${i+1}: user/repo, Civitai link or URL" aria-label="LoRA ${i+1} source">`
|
| 879 |
+
+ `<input class="num" type="number" min="0" max="2" step="0.05" aria-label="LoRA ${i+1} weight" title="Weight"></div>`).join('');
|
| 880 |
+
box.querySelectorAll('.lora-row').forEach(row => {
|
| 881 |
+
const i = +row.dataset.i, [u, w] = row.querySelectorAll('input');
|
| 882 |
+
u.addEventListener('input', () => { P.loras[i].url = u.value; syncLoraTag(); save(); });
|
| 883 |
+
w.addEventListener('change', () => { const v = clamp(Math.round(+w.value * 20) / 20 || 0, 0, 2); P.loras[i].w = v; w.value = v; save(); });
|
| 884 |
+
});
|
| 885 |
+
}
|
| 886 |
+
box.querySelectorAll('.lora-row').forEach(row => {
|
| 887 |
+
const i = +row.dataset.i, [u, w] = row.querySelectorAll('input');
|
| 888 |
+
if (document.activeElement !== u) u.value = P.loras[i].url;
|
| 889 |
+
if (document.activeElement !== w) w.value = P.loras[i].w;
|
| 890 |
+
});
|
| 891 |
+
syncLoraTag();
|
| 892 |
+
}
|
| 893 |
+
function syncLoraTag(){
|
| 894 |
+
const n = P.loras.filter(l => l.url.trim()).length, tag = $('#loraTag');
|
| 895 |
+
tag.textContent = n ? `${n} active` : 'Off'; tag.className = 'tag' + (n ? '' : ' tag-neutral');
|
| 896 |
+
$('#loraFold').classList.toggle('on', n > 0);
|
| 897 |
+
$('#loraRows').querySelectorAll('.lora-row').forEach(r => r.classList.toggle('on', !!P.loras[+r.dataset.i].url.trim()));
|
| 898 |
+
}
|
| 899 |
+
function loraArgs(){
|
| 900 |
+
normLoras();
|
| 901 |
+
return P.loras.flatMap(l => l.url.trim() ? ['Custom URL', l.url.trim(), +l.w] : ['None', '', 1.0]);
|
| 902 |
+
}
|
| 903 |
function syncCtl(){
|
| 904 |
const mid = modeId(P.ctl), ui = MODE_UI[mid], d = cdef(P.ctl);
|
| 905 |
document.querySelectorAll('#modes button').forEach(b => { const on = b.dataset.m === P.ctl; b.setAttribute('aria-checked', on); b.tabIndex = on ? 0 : -1; });
|
|
|
|
| 1478 |
job = client.submit('/generate', [P.prompt, P.negative, P.prefix, P.model, P.width, P.height, P.steps, +P.cfg, +P.shift, P.seed,
|
| 1479 |
P.ctl, img, mask, +P.ctlStrength, +P.ctlStart, +P.ctlEnd,
|
| 1480 |
P.poseSource, mid === 'pose' ? (P.poseJson || '') : '', P.poseHands, P.poseFace, P.poseFeet, P.poseFit, P.poseStyle, P.poseMax,
|
| 1481 |
+
...loraArgs()]); // LoRA slots 1-3
|
| 1482 |
}
|
| 1483 |
S.job = job;
|
| 1484 |
for await (const m of job){
|