From dc788f92b3afbf03360174dae62c18e2e9c06655 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 23 Aug 2022 10:19:11 -0400 Subject: [PATCH 1/3] in output directory, new image files always start with the number higher than the previous maximum filename to ensure alphabetic sort==chronological sort --- ldm/simplet2i.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index daae2293d9..62683259bf 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -449,12 +449,12 @@ The vast majority of these arguments default to reasonable values. revision = 1 if previousname is None: - # count up until we find an unfilled slot - dir_list = [a.split('.',1)[0] for a in os.listdir(outdir)] - uniques = dict.fromkeys(dir_list,True) - basecount = 1 - while f'{basecount:06}' in uniques: - basecount += 1 + # sort reverse alphabetically until we find max+1 + dirlist = sorted(os.listdir(outdir),reverse=True) + # find the first filename that matches our pattern or return 000000.0.png + filename = next((f for f in dirlist if re.match('^(\d+)\..*\.png',f)),'0000000.0.png') + basecount = int(filename.split('.',1)[0]) + basecount += 1 if grid_count is not None: grid_label = f'grid#1-{grid_count}' filename = f'{basecount:06}.{seed}.{grid_label}.png' From 1f2e52a1d61907605329826ff6d398ca6eaffdb4 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 23 Aug 2022 10:39:18 -0400 Subject: [PATCH 2/3] fixed filename generation so that newer files are always chronologically later --- README.md | 6 ++++++ scripts/dream.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9ed76208aa..a8f59ea913 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,11 @@ completely). The default is 0.75, and ranges from 0.25-0.75 give interesting res ## Changes +* v1.06 (23 August 2022) + * Image filenames will now never fill gaps in the sequence, but will be assigned the + next higher name in the chosen directory. This ensures that the alphabetic and chronological + sort orders are the same. + * v1.05 (22 August 2022 - after the drop) * Filenames now use the following formats: 000010.95183149.png -- Two files produced by the same command (e.g. -n2), @@ -474,6 +479,7 @@ optional arguments: --f F downsampling factor --n_samples N_SAMPLES how many samples to produce for each given prompt. A.k.a. batch size + (note that the seeds for each image in the batch will be unavailable) --n_rows N_ROWS rows in the grid (default: n_samples) --scale SCALE unconditional guidance scale: eps = eps(x, empty) + scale * (eps(x, cond) - eps(x, empty)) --from-file FROM_FILE diff --git a/scripts/dream.py b/scripts/dream.py index 0e511f7789..84c052f0e9 100755 --- a/scripts/dream.py +++ b/scripts/dream.py @@ -263,8 +263,8 @@ def create_argv_parser(): choices=['plms','ddim', 'klms'], default='klms', help="which sampler to use (klms) - can only be set on command line") - parser.add_argument('-o', - '--outdir', + parser.add_argument('--outdir', + '-o', type=str, default="outputs/img-samples", help="directory in which to place generated images and a log of prompts and seeds") @@ -276,8 +276,8 @@ def create_cmd_parser(): parser.add_argument('prompt') parser.add_argument('-s','--steps',type=int,help="number of steps") parser.add_argument('-S','--seed',type=int,help="image seed") - parser.add_argument('-n','--iterations',type=int,default=1,help="number of samplings to perform") - parser.add_argument('-b','--batch_size',type=int,default=1,help="number of images to produce per sampling") + parser.add_argument('-n','--iterations',type=int,default=1,help="number of samplings to perform (slower, but will provide seeds for individual images)") + parser.add_argument('-b','--batch_size',type=int,default=1,help="number of images to produce per sampling (will not provide seeds for individual images!)") parser.add_argument('-W','--width',type=int,help="image width, multiple of 64") parser.add_argument('-H','--height',type=int,help="image height, multiple of 64") parser.add_argument('-C','--cfg_scale',default=7.5,type=float,help="prompt configuration scale") From a21156e3e3357f10663a93777c340babd8eb678c Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Tue, 23 Aug 2022 10:44:33 -0400 Subject: [PATCH 3/3] removed the reference to the mod-deleted Reddit walkthru of prompt weighting usage --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 5582077a19..48dbc60815 100644 --- a/README.md +++ b/README.md @@ -98,9 +98,7 @@ This will tell the sampler to invest 25% of its effort on the tabby cat aspect of the image and 75% on the white duck aspect (surprisingly, this example actually works). The prompt weights can use any combination of integers and floating point numbers, and they -do not need to add up to 1. A practical example of using this type of -weighting is described here: -https://www.reddit.com/r/StableDiffusion/comments/wvb7q7/using_prompt_weights_to_tweak_an_image_with/ +do not need to add up to 1. ## Changes