diff --git a/javascript/hints.js b/javascript/hints.js index b43f7bbd..ed79796f 100644 --- a/javascript/hints.js +++ b/javascript/hints.js @@ -57,14 +57,13 @@ titles = { "Interrogate": "Reconstruct prompt from existing image and put it into the prompt field.", - "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.", - "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date]; leave empty for default.", + "Images filename pattern": "Use following tags to define how filenames for images are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date], [job_timestamp]; leave empty for default.", + "Directory name pattern": "Use following tags to define how subdirectories for images and grids are chosen: [steps], [cfg], [prompt], [prompt_spaces], [width], [height], [styles], [sampler], [seed], [model_hash], [prompt_words], [date], [job_timestamp]; leave empty for default.", "Max prompt words": "Set the maximum number of words to be used in the [prompt_words] option; ATTENTION: If the words are too long, they may exceed the maximum length of the file path that the system can handle", "Loopback": "Process an image, use it as an input, repeat.", "Loops": "How many times to repeat processing an image and using it as input for the next iteration", - "Style 1": "Style to apply; styles have components for both positive and negative prompts and apply to both", "Style 2": "Style to apply; styles have components for both positive and negative prompts and apply to both", "Apply style": "Insert selected styles into prompt fields", diff --git a/modules/images.py b/modules/images.py index 642cde36..ae0e6304 100644 --- a/modules/images.py +++ b/modules/images.py @@ -295,6 +295,7 @@ def apply_filename_pattern(x, p, seed, prompt): x = x.replace("[model_hash]", shared.sd_model.sd_model_hash) x = x.replace("[date]", datetime.date.today().isoformat()) + x = x.replace("[job_timestamp]", shared.state.job_timestamp) if cmd_opts.hide_ui_dir_config: x = re.sub(r'^[\\/]+|\.{2,}[\\/]+|[\\/]+\.{2,}', '', x) diff --git a/modules/scripts.py b/modules/scripts.py index 9ab207dc..202374e6 100644 --- a/modules/scripts.py +++ b/modules/scripts.py @@ -119,6 +119,7 @@ class ScriptRunner: continue for control in controls: + control.custom_script_source = os.path.basename(script.filename) control.visible = False inputs += controls diff --git a/modules/shared.py b/modules/shared.py index 1ce6eefc..c32da110 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -4,6 +4,7 @@ import json import os import gradio as gr import tqdm +import datetime import modules.artists from modules.paths import script_path, sd_path @@ -65,6 +66,7 @@ class State: job = "" job_no = 0 job_count = 0 + job_timestamp = 0 sampling_step = 0 sampling_steps = 0 current_latent = None @@ -78,6 +80,8 @@ class State: self.job_no += 1 self.sampling_step = 0 self.current_image_sampling_step = 0 + def get_job_timestamp(self): + return datetime.datetime.now().strftime("%Y%m%d%H%M%S") state = State() diff --git a/modules/ui.py b/modules/ui.py index 05d33563..f7ca5588 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1040,6 +1040,9 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): def loadsave(path, x): def apply_field(obj, field, condition=None): key = path + "/" + field + + if getattr(obj,'custom_script_source',None) is not None: + key = 'customscript/' + obj.custom_script_source + '/' + key if getattr(obj, 'do_not_save_to_config', False): return diff --git a/webui.py b/webui.py index 64c9d462..9ea5f5a3 100644 --- a/webui.py +++ b/webui.py @@ -50,6 +50,7 @@ def wrap_gradio_gpu_call(func): shared.state.sampling_step = 0 shared.state.job_count = -1 shared.state.job_no = 0 + shared.state.job_timestamp = shared.state.get_job_timestamp() shared.state.current_latent = None shared.state.current_image = None shared.state.current_image_sampling_step = 0