mcmonkeyprojects / SwarmUI

SwarmUI (formerly StableSwarmUI), A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.
MIT License
1.33k stars 96 forks source link

OutpathBuilder - support (short-)hashes of parameters when building path. #188

Closed brendanhoar closed 1 month ago

brendanhoar commented 2 months ago

Feature Idea

On A1111-ism I preferred was the ability to build the output path using the shorthash of the prompt/negative prompt/model/etc. This provided a less messy output in some cases. Consider supporting, minimally hashes of the prompt/negative prompt as well as the AutoV3 hash of the primary model in addition to the strings/names.

E.g. my A1111 style paths would, among other parameters, include both the hash of the model and the model filename, but only the hashes of the prompts,

For prompts, many prompts share a significantly long identical preamble and it becomes difficult using the path semantics to bucket them precisely without the hashes.

Other

No response

mcmonkey4eva commented 2 months ago

whaat the heck is a prompt hash

brendanhoar commented 2 months ago

https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#filenames-format

CW: python excerpts :P

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/images.py#L400

...
class FilenameGenerator:
    replacements = {
...
        'prompt_hash': lambda self, *args: self.string_hash(self.prompt, *args),
        'negative_prompt_hash': lambda self, *args: self.string_hash(self.p.negative_prompt, *args),
        'full_prompt_hash': lambda self, *args: self.string_hash(f"{self.p.prompt} {self.p.negative_prompt}", *args),  # a space in between to create a unique string
...

    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]
...
mcmonkey4eva commented 2 months ago

... so literally a sha256 of random parameter text? that sounds horrible ow

brendanhoar commented 2 months ago

Just the first 8 characters of the sha256 of each of the prompt text(s).

mcmonkey4eva commented 1 month ago

That is an extremely silly feature, but, eh, there ya go