From 49f8730814db72ddb811f75abe62541d3df6a838 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 27 Nov 2023 08:07:12 -0500 Subject: [PATCH] fix save text file for manually saved images --- CHANGELOG.md | 33 ++++++++++++++++++--------------- html/locale_en.json | 2 +- modules/shared.py | 2 +- modules/ui_common.py | 11 +++++++++++ 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48f70e970..b90889aa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,31 +1,34 @@ # Change Log for SD.Next -## Update for 2023-11-24 +## Update for 2023-11-26 Note: Release pending `diffusers==0.24` - **Diffusers** - **IP adapter** - - Lightweight implementation of T2I adapters which can guide generation towards specific image style - - Supports most T2I models, not limited to SD + - Lightweight implementation of T2I adapters which can guide generation towards specific image style + - Supports most T2I models, not limited to SD - **HDR latent control**, based on [article](https://huggingface.co/blog/TimothyAlexisVass/explaining-the-sdxl-latent-space#long-prompts-at-high-guidance-scales-becoming-possible) - In *Advanced* params - - Allows control of *latent clamping*, *color centering* and *range maximimization* - - Supported by *XYZ grid* + - Allows control of *latent clamping*, *color centering* and *range maximimization* + - Supported by *XYZ grid* - **Kandinsky 3** support - download using built-in model downloader or simply select from networks -> reference - - this model is absolutely massive at 27.5GB at fp16, so be patient + - this model is absolutely massive at 27.5GB at fp16, so be patient - model params count is at 11.9B (compared to SD-XL at 3.3B) and its trained on mixed resolutions from 256px to 1024px - - use either model offload or sequential cpu offload to be able to use it - - better autodetection of *inpaint* and *instruct* pipelines - - support long seconary prompt for refiner + - use either model offload or sequential cpu offload to be able to use it + - better autodetection of *inpaint* and *instruct* pipelines + - support long seconary prompt for refiner +- **Model merge** + - add sd-xl rebasin support, thanks @AI-Casanova - **General** - - log level defaults to info for console and debug for log file - - better prompt display in process tab - - increase maximum lora cache values - - fix controlnet compatibility issues in original backend - - fix python 3.9 compatibility issues - - fix img2img/inpaint paste params + - log level defaults to info for console and debug for log file + - better prompt display in process tab + - increase maximum lora cache values + - fix controlnet compatibility issues in original backend + - fix img2img/inpaint paste params + - fix save text file for manually saved images + - fix python 3.9 compatibility issues ## Update for 2023-11-23 diff --git a/html/locale_en.json b/html/locale_en.json index 45074cb63..a475df59e 100644 --- a/html/locale_en.json +++ b/html/locale_en.json @@ -445,7 +445,7 @@ {"id":"","label":"File format for grids","localized":"","hint":""}, {"id":"","label":"Add extended info (seed, prompt) to filename when saving grid","localized":"","hint":""}, {"id":"","label":"Grid row count","localized":"","hint":"Use -1 for autodetect and 0 for it to be same as batch size"}, - {"id":"","label":"Create text file next to every image with generation parameters","localized":"","hint":""}, + {"id":"","label":"Create info file for each every image","localized":"","hint":""}, {"id":"","label":"Create JSON log file for each saved image","localized":"","hint":"Save image information to a JSON file"}, {"id":"","label":"Save copy of image before doing face restoration","localized":"","hint":""}, {"id":"","label":"Save copy of image before applying hires","localized":"","hint":""}, diff --git a/modules/shared.py b/modules/shared.py index 7c7304d0c..2ca3ce5c7 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -411,7 +411,7 @@ options_templates.update(options_section(('saving-images', "Image Options"), { "image_sep_metadata": OptionInfo("

Metadata/Logging

", "", gr.HTML), "image_metadata": OptionInfo(True, "Include metadata in saved images"), - "save_txt": OptionInfo(False, "Create text file next to every image with generation parameters"), + "save_txt": OptionInfo(False, "Create info file for each every image"), "save_log_fn": OptionInfo("", "Create JSON log file for each saved image", component_args=hide_dirs), "image_watermark_enabled": OptionInfo(False, "Include watermark in saved images"), "image_watermark": OptionInfo('', "Image watermark string"), diff --git a/modules/ui_common.py b/modules/ui_common.py index 0b9b6ddb1..69dcb2551 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -134,6 +134,17 @@ def save_files(js_data, images, html_info, index): shutil.copy(fullfn, destination) shared.log.info(f'Copying image: file="{fullfn}" folder="{destination}"') tgt_filename = os.path.join(destination, os.path.basename(fullfn)) + if shared.opts.save_txt: + try: + from PIL import Image + image = Image.open(fullfn) + info, _ = images.read_info_from_image(image) + filename_txt = f"{os.path.splitext(tgt_filename)[0]}.txt" + with open(filename_txt, "w", encoding="utf8") as file: + file.write(f"{info}\n") + shared.log.debug(f'Saving: text="{filename_txt}"') + except Exception as e: + shared.log.warning(f'Image description save failed: {filename_txt} {e}') modules.script_callbacks.image_save_btn_callback(tgt_filename) else: image = image_from_url_text(filedata)