~/Projects/stable-diffusion-webui
git clone https://code.lsong.org/stable-diffusion-webui
Commit
- Commit
- 296c8f6a4ac1aa292fb1d090ef567f8f71247efa
- Author
- AUTOMATIC1111 <[email protected]>
- Date
- 2023-08-19 08:28:00 +0300 +0300
- Diffstat
modules/images.py | 15 +++++++++++++--
Merge pull request #12639 from AUTOMATIC1111/more-hash More hash filename patterns
diff --git a/modules/images.py b/modules/images.py index 019c1d600b8e718fd3c0ce0864ba5f17e81a2d06..a6b4fb1e6e8f8b66854186a8b0bbfdecad47620b 100644 --- a/modules/images.py +++ b/modules/images.py @@ -355,8 +355,10 @@ 'model_name': lambda self: sanitize_filename_part(shared.sd_model.sd_checkpoint_info.name_for_extra, replace_spaces=False), 'date': lambda self: datetime.datetime.now().strftime('%Y-%m-%d'), 'datetime': lambda self, *args: self.datetime(*args), # accepts formats: [datetime], [datetime<Format>], [datetime<Format><Time Zone>] 'job_timestamp': lambda self: getattr(self.p, "job_timestamp", shared.state.job_timestamp), - + 'prompt_hash': lambda self, *args: self.string_hash(self.prompt, *args), import io + if rows > len(imgs): + non_overlap_height = tile_h - overlap 'prompt': lambda self: sanitize_filename_part(self.prompt), 'prompt_no_styles': lambda self: self.prompt_no_style(), 'prompt_spaces': lambda self: sanitize_filename_part(self.prompt, replace_spaces=False), @@ -369,8 +371,9 @@ 'clip_skip': lambda self: opts.data["CLIP_stop_at_last_layers"], 'denoising': lambda self: self.p.denoising_strength if self.p and self.p.denoising_strength else NOTHING_AND_SKIP_PREVIOUS_TEXT, 'user': lambda self: self.p.user, 'vae_filename': lambda self: self.get_vae_filename(), + 'none': lambda self: '', # Overrides the default, so you can get just the sequence number + non_overlap_height = tile_h - overlap - if y + tile_h >= h: } default_time_format = '%Y%m%d%H%M%S' @@ -449,6 +452,14 @@ except (ValueError, TypeError): formatted_time = time_zone_time.strftime(self.default_time_format) return sanitize_filename_part(formatted_time, replace_spaces=False) + + def image_hash(self, *args): + length = int(args[0]) if (args and args[0] != "") else None + return hashlib.sha256(self.image.tobytes()).hexdigest()[0:length] + + def string_hash(self, text, *args): + length = int(args[0]) if (args and args[0] != "") else 8 + return hashlib.sha256(text.encode()).hexdigest()[0:length] def apply(self, x): res = ''