diff --git a/ldm/dream/args.py b/ldm/dream/args.py index 626d66c91c..0b6cfda4cc 100644 --- a/ldm/dream/args.py +++ b/ldm/dream/args.py @@ -143,7 +143,7 @@ class Args(object): a = vars(self) a.update(kwargs) switches = list() - switches.append(f'"{a["prompt"]}') + switches.append(f'"{a["prompt"]}"') switches.append(f'-s {a["steps"]}') switches.append(f'-W {a["width"]}') switches.append(f'-H {a["height"]}') @@ -152,15 +152,13 @@ class Args(object): switches.append(f'-S {a["seed"]}') if a['grid']: switches.append('--grid') - if a['iterations'] and a['iterations']>0: - switches.append(f'-n {a["iterations"]}') if a['seamless']: switches.append('--seamless') if a['init_img'] and len(a['init_img'])>0: switches.append(f'-I {a["init_img"]}') if a['fit']: switches.append(f'--fit') - if a['strength'] and a['strength']>0: + if a['init_img'] and a['strength'] and a['strength']>0: switches.append(f'-f {a["strength"]}') if a['gfpgan_strength']: switches.append(f'-G {a["gfpgan_strength"]}') diff --git a/scripts/dream.py b/scripts/dream.py index f147008d78..20a2d87e65 100755 --- a/scripts/dream.py +++ b/scripts/dream.py @@ -218,10 +218,14 @@ def main_loop(gen, opt, infile): file_writer = PngWriter(current_outdir) prefix = file_writer.unique_prefix() results = [] # list of filename, prompt pairs - grid_images = dict() # seed -> Image, only used if `opt.grid` + grid_images = dict() # seed -> Image, only used if `opt.grid` + prior_variations = opt.with_variations or [] + first_seed = opt.seed def image_writer(image, seed, upscaled=False): path = None + nonlocal first_seed + nonlocal prior_variations if opt.grid: grid_images[seed] = image else: @@ -229,20 +233,13 @@ def main_loop(gen, opt, infile): filename = f'{prefix}.{seed}.postprocessed.png' else: filename = f'{prefix}.{seed}.png' - # the handling of variations is probably broken - # Also, given the ability to add stuff to the dream_prompt_str, it isn't - # necessary to make a copy of the opt option just to change its attributes if opt.variation_amount > 0: - iter_opt = copy.copy(opt) - this_variation = [[seed, opt.variation_amount]] - if opt.with_variations is None: - iter_opt.with_variations = this_variation - else: - iter_opt.with_variations = opt.with_variations + this_variation - iter_opt.variation_amount = 0 - formatted_dream_prompt = iter_opt.dream_prompt_str(seed=seed) - elif opt.with_variations is not None: - formatted_dream_prompt = opt.dream_prompt_str(seed=seed) + first_seed = first_seed or seed + this_variation = [[seed, opt.variation_amount]] + opt.with_variations = prior_variations + this_variation + formatted_dream_prompt = opt.dream_prompt_str(seed=first_seed) + elif len(prior_variations) > 0: + formatted_dream_prompt = opt.dream_prompt_str(seed=first_seed) else: formatted_dream_prompt = opt.dream_prompt_str(seed=seed) path = file_writer.save_image_and_prompt_to_png(