Skip to content

Commit

Permalink
negative -S indexing recovers correct previous seed; closes issue inv…
Browse files Browse the repository at this point in the history
  • Loading branch information
lstein committed Sep 11, 2022
1 parent 839e30e commit 8748370
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -242,8 +243,8 @@ def main_loop(t2i, outdir, prompt_as_dir, parser, infile):
# Here is where the images are actually generated!
try:
file_writer = PngWriter(current_outdir)
prefix = file_writer.unique_prefix()
seeds = set()
prefix = file_writer.unique_prefix()
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):
Expand Down Expand Up @@ -275,7 +276,7 @@ def image_writer(image, seed, upscaled=False):
# 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))

Expand Down

0 comments on commit 8748370

Please sign in to comment.