diff --git a/ldm/dream/server.py b/ldm/dream/server.py index 22a60412f1..384cbc37a8 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -75,8 +75,8 @@ class DreamServer(BaseHTTPRequestHandler): seamless = 'seamless' in post_data cfgscale = float(post_data['cfgscale']) sampler_name = post_data['sampler'] - variation_amount = float(post_data['variation_amount']) - with_variations = post_data['with_variations'] + variation_amount = float(post_data['variation_amount']) if int(post_data['seed']) == -1 else 0.0 + with_variations = post_data['with_variations'] if int(post_data['seed']) == -1 else '' gfpgan_strength = float(post_data['gfpgan_strength']) if gfpgan_model_exists else 0 upscale_level = post_data['upscale_level'] upscale_strength = post_data['upscale_strength'] @@ -129,7 +129,8 @@ class DreamServer(BaseHTTPRequestHandler): name = f'{prefix}.{seed}.png' path = pngwriter.save_image_and_prompt_to_png(image, f'{prompt} -S{seed}', name) - config['seed'] = seed + if int(config['seed']) == -1: + config['seed'] = seed # Append post_data to log, but only once! if not upscaled: with open(os.path.join(self.outdir, "dream_web_log.txt"), "a") as log: diff --git a/static/dream_web/index.js b/static/dream_web/index.js index 2d2dce1452..de70661b67 100644 --- a/static/dream_web/index.js +++ b/static/dream_web/index.js @@ -9,7 +9,13 @@ function toBase64(file) { function appendOutput(src, seed, config) { let outputNode = document.createElement("figure"); - let altText = seed.toString() + " | " + config.prompt; + + let variations = config.with_variations; + if (config.variation_amount > 0) { + variations = (variations ? variations + ',' : '') + seed + ':' + config.variation_amount; + } + let baseseed = (config.with_variations || config.variation_amount > 0) ? config.seed : seed; + let altText = baseseed + ' | ' + (variations ? variations + ' | ' : '') + config.prompt; const figureContents = ` @@ -19,7 +25,7 @@ function appendOutput(src, seed, config) { `; outputNode.innerHTML = figureContents; - let figcaption = outputNode.querySelector('figcaption') + let figcaption = outputNode.querySelector('figcaption'); // Reload image config figcaption.addEventListener('click', () => { @@ -28,21 +34,11 @@ function appendOutput(src, seed, config) { if (k == 'initimg') { continue; } form.querySelector(`*[name=${k}]`).value = config[k]; } - if (config.variation_amount > 0 || config.with_variations != '') { - document.querySelector("#seed").value = config.seed; - } else { - document.querySelector("#seed").value = seed; - } - if (config.variation_amount > 0) { - let oldVarAmt = document.querySelector("#variation_amount").value - let oldVariations = document.querySelector("#with_variations").value - let varSep = '' - document.querySelector("#variation_amount").value = 0; - if (document.querySelector("#with_variations").value != '') { - varSep = "," - } - document.querySelector("#with_variations").value = oldVariations + varSep + seed + ':' + config.variation_amount + document.querySelector("#seed").value = baseseed; + document.querySelector("#with_variations").value = variations || ''; + if (document.querySelector("#variation_amount").value <= 0) { + document.querySelector("#variation_amount").value = 0.2; } saveFields(document.querySelector("#generate-form"));