From f6284777e6d79bd3d1e85b83aa72d774299a7403 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 6 Sep 2022 17:12:39 -0400 Subject: [PATCH] Squashed commit of the following: commit 7d1344282d942a33dcecda4d5144fc154ec82915 Merge: caf4ea3 ebeb556 Author: Lincoln Stein Date: Mon Sep 5 10:07:27 2022 -0400 Merge branch 'development' of github.com:WebDev9000/stable-diffusion into WebDev9000-development commit ebeb556af9c99b491a83c72f83512683a02a82ad Author: Web Dev 9000 Date: Sun Sep 4 18:05:15 2022 -0700 Fixed unintentionally removed lines commit ff2c4b9a1b773b95686d5f3e546e1194de054694 Author: Web Dev 9000 Date: Sun Sep 4 17:50:13 2022 -0700 Add ability to recreate variations via image click commit c012929cdae7c37aa3b3b4fa2e7de465458f732a Author: Web Dev 9000 Date: Sun Sep 4 14:35:33 2022 -0700 Add files via upload commit 02a601899214adfe4536ce0ba67694a46319fd51 Author: Web Dev 9000 Date: Sun Sep 4 14:35:07 2022 -0700 Add files via upload --- ldm/dream/server.py | 30 ++++++++++++++++++++++++++++++ static/dream_web/index.css | 3 +++ static/dream_web/index.html | 37 +++++++++++++++++++++---------------- static/dream_web/index.js | 21 ++++++++++++++++++--- 4 files changed, 72 insertions(+), 19 deletions(-) diff --git a/ldm/dream/server.py b/ldm/dream/server.py index 10cd7d722ed..f22c5847e22 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -75,6 +75,8 @@ def do_POST(self): 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'] 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'] @@ -82,6 +84,30 @@ def do_POST(self): progress_images = 'progress_images' in post_data seed = self.model.seed if int(post_data['seed']) == -1 else int(post_data['seed']) + if with_variations != '': + parts = [] + broken = False + for part in with_variations.split(','): + seed_and_weight = part.split(':') + if len(seed_and_weight) != 2: + print(f'could not parse with_variation part "{part}"') + broken = True + break + try: + vseed = int(seed_and_weight[0]) + vweight = float(seed_and_weight[1]) + except ValueError: + print(f'could not parse with_variation part "{part}"') + broken = True + break + parts.append([vseed, vweight]) + if broken: + raise CanceledException + if len(parts) > 0: + with_variations = parts + else: + with_variations = None + self.canceled.clear() print(f">> Request to generate with prompt: {prompt}") # In order to handle upscaled images, the PngWriter needs to maintain state @@ -163,6 +189,8 @@ def image_progress(sample, step): height = height, seed = seed, steps = steps, + variation_amount = variation_amount, + with_variations = with_variations, gfpgan_strength = gfpgan_strength, upscale = upscale, sampler_name = sampler_name, @@ -184,6 +212,8 @@ def image_progress(sample, step): cfg_scale = cfgscale, seed = seed, steps = steps, + variation_amount = variation_amount, + with_variations = with_variations, sampler_name = sampler_name, width = width, height = height, diff --git a/static/dream_web/index.css b/static/dream_web/index.css index aa5e3497703..117db7b5fbb 100644 --- a/static/dream_web/index.css +++ b/static/dream_web/index.css @@ -125,6 +125,9 @@ label { #txt2img { background-color: #DCDCDC; } +#variations { + background-color: #EEEEEE; +} #img2img { background-color: #F5F5F5; } diff --git a/static/dream_web/index.html b/static/dream_web/index.html index 980bd0fcc5e..466e165ffde 100644 --- a/static/dream_web/index.html +++ b/static/dream_web/index.html @@ -23,7 +23,7 @@

Stable Diffusion Dream Server

+
@@ -40,7 +40,7 @@

Stable Diffusion Dream Server

- + @@ -68,23 +68,28 @@

Stable Diffusion Dream Server

- - - -
-
- - - -
- - - - + + +
+ + + + +
+
+ + + +
+ + + + +
@@ -105,7 +110,7 @@

Stable Diffusion Dream Server


- +
Postprocessing...1/3
diff --git a/static/dream_web/index.js b/static/dream_web/index.js index e2806d4d107..4d1fbe3778a 100644 --- a/static/dream_web/index.js +++ b/static/dream_web/index.js @@ -25,10 +25,25 @@ function appendOutput(src, seed, config) { figcaption.addEventListener('click', () => { let form = document.querySelector("#generate-form"); for (const [k, v] of new FormData(form)) { - if (k == 'initimg') { continue; } - form.querySelector(`*[name=${k}]`).value = config[k]; + 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 = seed; saveFields(document.querySelector("#generate-form")); });