From 9c7e1291a77c32ca6dcefb17442a692ce4ad3d2b Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 11 Nov 2023 07:59:48 -0500 Subject: [PATCH] move save params to after generate --- html/reference.json | 5 ----- modules/images.py | 2 ++ modules/processing.py | 4 ---- modules/ui_tempdir.py | 6 +++++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/html/reference.json b/html/reference.json index 49f85b189..86a3dab9f 100644 --- a/html/reference.json +++ b/html/reference.json @@ -23,11 +23,6 @@ "path": "segmind/tiny-sd", "desc": "Segmind's Tiny-SD offers a compact, efficient, and distilled version of Realistic Vision 4.0 and is up to 80% faster than SD1.5", "preview": "segmind--tiny-sd.jpg" - }, - "LCM SD-XL": { - "path": "latent-consistency/lcm-sdxl", - "desc": "Latent Consistencey Models enable swift inference with minimal steps on any pre-trained LDMs, including Stable Diffusion. By distilling classifier-free guidance into the model's input, LCM can generate high-quality images in very short inference time. LCM can generate quality images in as few as 3-4 steps, making it blazingly fast.", - "preview": "latent-consistency--lcm-sdxl.jpg" }, "LCM SD-1.5 Dreamshaper 7": { "path": "SimianLuo/LCM_Dreamshaper_v7", diff --git a/modules/images.py b/modules/images.py index 28046e159..38e7ebbcb 100644 --- a/modules/images.py +++ b/modules/images.py @@ -541,6 +541,8 @@ def atomically_save_image(): entry = { 'id': idx, 'filename': filename, 'time': datetime.datetime.now().isoformat(), 'info': exifinfo } entries.append(entry) shared.writefile(entries, fn, mode='w') + with open(os.path.join(paths.data_path, "params.txt"), "w", encoding="utf8") as file: + file.write(exifinfo) save_queue.task_done() diff --git a/modules/processing.py b/modules/processing.py index 19655eb36..8a87ea68a 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -851,10 +851,6 @@ def infotext(_inxex=0): # dummy function overriden if there are iterations modules.extra_networks.activate(p, extra_network_data) if p.scripts is not None and isinstance(p.scripts, modules.scripts.ScriptRunner): p.scripts.process_batch(p, batch_number=n, prompts=p.prompts, seeds=p.seeds, subseeds=p.subseeds) - if n == 0: - with open(os.path.join(modules.paths.data_path, "params.txt"), "w", encoding="utf8") as file: - processed = Processed(p, [], p.seed, "") - file.write(processed.infotext(p, 0)) step_multiplier = 1 sampler_config = modules.sd_samplers.find_sampler_config(p.sampler_name) step_multiplier = 2 if sampler_config and sampler_config.options.get("second_order", False) else 1 diff --git a/modules/ui_tempdir.py b/modules/ui_tempdir.py index f9b38de14..25f59125e 100644 --- a/modules/ui_tempdir.py +++ b/modules/ui_tempdir.py @@ -4,7 +4,7 @@ from pathlib import Path import gradio as gr from PIL import Image, PngImagePlugin -from modules import shared, errors +from modules import shared, errors, paths Savedfile = namedtuple("Savedfile", ["name"]) @@ -69,6 +69,10 @@ def pil_to_temp_file(self, img: Image, dir: str, format="png") -> str: # pylint: name = tmp.name img.save(name, pnginfo=(metadata if use_metadata else None)) shared.log.debug(f'Saving temp: image="{name}"') + params = ', '.join([f'{k}: {v}' for k, v in img.info.items()]) + params = params[12:] if params.startswith('parameters: ') else params + with open(os.path.join(paths.data_path, "params.txt"), "w", encoding="utf8") as file: + file.write(params) return name