diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 13:41:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 13:41:19 +0000 |
commit | 8651943cf9038ef937f0f35640f87fb67490be95 (patch) | |
tree | 9c5740d1f43eb0963914df50a2457237243031c5 | |
parent | 7428fb5176ccfd203bddcfa30d75c8df5a772cb4 (diff) | |
parent | e7d624574d476e008d8c148ba5b74bf13b5834de (diff) | |
download | stable-diffusion-webui-gfx803-8651943cf9038ef937f0f35640f87fb67490be95.tar.gz stable-diffusion-webui-gfx803-8651943cf9038ef937f0f35640f87fb67490be95.tar.bz2 stable-diffusion-webui-gfx803-8651943cf9038ef937f0f35640f87fb67490be95.zip |
Merge pull request #9445 from gakada/master
Add [batch_number] and [generation_number] filename patterns
-rw-r--r-- | modules/images.py | 6 | ||||
-rw-r--r-- | modules/processing.py | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py index 559de810..9cd17ddd 100644 --- a/modules/images.py +++ b/modules/images.py @@ -352,6 +352,8 @@ class FilenameGenerator: 'prompt_no_styles': lambda self: self.prompt_no_style(),
'prompt_spaces': lambda self: sanitize_filename_part(self.prompt, replace_spaces=False),
'prompt_words': lambda self: self.prompt_words(),
+ 'batch_number': lambda self: self.p.batch_index + 1,
+ 'generation_number': lambda self: self.p.iteration * self.p.batch_size + self.p.batch_index + 1,
'hasprompt': lambda self, *args: self.hasprompt(*args), #accept formats:[hasprompt<prompt1|default><prompt2>..]
'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"],
}
@@ -421,6 +423,10 @@ class FilenameGenerator: for m in re_pattern.finditer(x):
text, pattern = m.groups()
+
+ if pattern is not None and (pattern.lower() == 'batch_number' and self.p.batch_size == 1 or pattern.lower() == 'generation_number' and self.p.n_iter == 1 and self.p.batch_size == 1):
+ continue
+
res += text
if pattern is None:
diff --git a/modules/processing.py b/modules/processing.py index 8d7b2462..a48fff99 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -683,6 +683,8 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: p.scripts.postprocess_batch(p, x_samples_ddim, batch_number=n)
for i, x_sample in enumerate(x_samples_ddim):
+ p.batch_index = i
+
x_sample = 255. * np.moveaxis(x_sample.cpu().numpy(), 0, 2)
x_sample = x_sample.astype(np.uint8)
@@ -731,7 +733,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed: if opts.return_mask:
output_images.append(image_mask)
-
+
if opts.return_mask_composite:
output_images.append(image_mask_composite)
|