negative -S indexing recovers correct previous seed; closes issue #476

This commit is contained in:
Lincoln Stein 2022-09-11 10:22:32 -04:00
parent 839e30e4b8
commit 8748370f44

View File

@ -185,6 +185,7 @@ def main_loop(t2i, outdir, prompt_as_dir, parser, infile):
continue
if opt.seed is not None and opt.seed < 0: # retrieve previous value!
try:
print(f'last seeds = {last_seeds}, opt.seed={opt.seed}')
opt.seed = last_seeds[opt.seed]
print(f'reusing previous seed {opt.seed}')
except IndexError:
@ -243,7 +244,7 @@ def main_loop(t2i, outdir, prompt_as_dir, parser, infile):
try:
file_writer = PngWriter(current_outdir)
prefix = file_writer.unique_prefix()
seeds = set()
seeds = list()
results = [] # list of filename, prompt pairs
grid_images = dict() # seed -> Image, only used if `do_grid`
def image_writer(image, seed, upscaled=False):
@ -275,7 +276,7 @@ def main_loop(t2i, outdir, prompt_as_dir, parser, infile):
# only append to results if we didn't overwrite an earlier output
results.append([path, metadata_prompt])
seeds.add(seed)
seeds.append(seed)
t2i.prompt2image(image_callback=image_writer, **vars(opt))