mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy up generation of prompt when variations in use
This commit is contained in:
parent
c94b8cd959
commit
2faa116238
@ -101,7 +101,7 @@ class Generator():
|
||||
next_noise = self.get_noise(width,height)
|
||||
initial_noise = self.slerp(v_weight, initial_noise, next_noise)
|
||||
if self.variation_amount > 0:
|
||||
# random.seed() # reset RNG to an actually random state, so we can get a random seed for variations
|
||||
random.seed() # reset RNG to an actually random state, so we can get a random seed for variations
|
||||
seed = random.randrange(0,np.iinfo(np.uint32).max)
|
||||
return (seed, initial_noise)
|
||||
else:
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user