From eee82fbd323010b8ff5161a36f646932a3b73438 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 24 Aug 2022 14:16:48 +0530 Subject: [PATCH] Easier random seed control; Show the seed number used for a random image, incase it is good and can be refined further --- index.html | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5322b7ca..473028c1 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,7 @@
Advanced settings: [show]
- (use -1 for random seed)
+



@@ -118,6 +118,7 @@ async function makeImage() { btn.disabled = true; let outputMsg = document.querySelector('#outputMsg') + outputMsg.innerHTML = 'Fetching..' function logError(msg, res) { outputMsg.innerHTML = 'Error: ' + msg + '' @@ -125,6 +126,9 @@ async function makeImage() { setStatus('request', 'error', 'error') } + let random_seed = document.querySelector("#random_seed") + let seed = (random_seed.checked ? Math.floor(Math.random() * 10000) : document.querySelector('#seed').value) + let reqBody = { prompt: document.querySelector('#prompt').value, num_outputs: document.querySelector('#num_outputs').value, @@ -132,7 +136,7 @@ async function makeImage() { guidance_scale: document.querySelector('#guidance_scale').value / 10, width: document.querySelector('#width').value, height: document.querySelector('#height').value, - seed: document.querySelector('#seed').value, + seed: seed, } let res = '' let time = new Date().getTime() @@ -180,7 +184,7 @@ async function makeImage() { time = new Date().getTime() - time time /= 1000 - outputMsg.innerHTML = 'Processed in ' + time + ' seconds' + outputMsg.innerHTML = 'Processed in ' + time + ' seconds. Seed: ' + seed let images = document.querySelector('#images') images.innerHTML = '' @@ -205,6 +209,11 @@ async function makeImage() { } setStatus('request', 'done', 'success') + + if (random_seed.checked) { + let seedEl = document.querySelector("#seed") + seedEl.value = seed + } } document.querySelector('#makeImage').addEventListener('click', makeImage) @@ -227,6 +236,19 @@ function updateGuidanceScale() { guidanceScale.addEventListener('input', updateGuidanceScale) updateGuidanceScale() +let random_seed = document.querySelector("#random_seed") +function checkRandomSeed() { + let seed = document.querySelector("#seed") + if (random_seed.checked) { + seed.disabled = true + seed.value = "random" + } else { + seed.disabled = false + } +} +random_seed.addEventListener('input', checkRandomSeed) +checkRandomSeed() + setInterval(healthCheck, HEALTH_PING_INTERVAL * 1000)