diff --git a/ldm/dream/server.py b/ldm/dream/server.py index 0427cfd56b..0d809538b5 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -80,6 +80,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'] 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'] @@ -87,6 +89,30 @@ class DreamServer(BaseHTTPRequestHandler): 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 @@ -168,6 +194,8 @@ class DreamServer(BaseHTTPRequestHandler): height = height, seed = seed, steps = steps, + variation_amount = variation_amount, + with_variations = with_variations, gfpgan_strength = gfpgan_strength, upscale = upscale, sampler_name = sampler_name, @@ -189,6 +217,8 @@ class DreamServer(BaseHTTPRequestHandler): cfg_scale = cfgscale, seed = seed, steps = steps, + variation_amount = variation_amount, + with_variations = with_variations, sampler_name = sampler_name, width = width, height = height,