From d135fe138362f7f2733a14cc3b5312dd3dac7714 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 26 Oct 2023 07:02:44 -0400 Subject: [PATCH 1/2] fix fn sequence --- CHANGELOG.md | 111 +++++++++++--------- extensions-builtin/sd-extension-chainner | 2 +- extensions-builtin/sd-webui-agent-scheduler | 2 +- extensions-builtin/sd-webui-controlnet | 2 +- modules/images.py | 37 ++++--- 5 files changed, 88 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bc9c5b8b..95aa47a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,55 +1,67 @@ # Change Log for SD.Next -## Update for 2023-10-23 +## Update for 2023-10-25 -Service release addressing all zero-day issues reported so far... +*Note*: Pending release of `diffusers==0.22.0` -**Fixes** -- fix **freeu** for backend original and add it to xyz grid -- fix loading diffuser models in huggingface format from non-standard location -- fix default styles looking in wrong location -- fix missing upscaler folder on initial startup -- fix handling of relative path for models -- fix simple live preview device mismatch -- fix batch img2img -- fix diffusers samplers: dpm++ 2m, dpm++ 1s, deis -- fix new style filename template -- fix image name template using model name -- fix model path using relative path -- fix `torch-rocm` and `tensorflow-rocm` version detection, thanks @xangelix -- fix **chainner** upscalers color clipping -- fix for base+refiner workflow in diffusers mode: number of steps, diffuser pipe mode -- fix for prompt encoder with refiner in diffusers mode -- fix prompts-from-file saving incorrect metadata -- fix before-hires step -- fix diffusers switch from invalid model -- **directml** and **ipex** updates -- force second requirements check on startup -- remove lyco, multiple_tqdm -- enhance extension compatibility for exensions directly importing codeformers -- enhance extension compatibility for exensions directly accessing processing params -- css fixes -- clearly mark external themes in ui -- update `openvino`, thanks @disty0 -- update `typing-extensions` +Mostly service release with support for several new models and additional optimizations... -### Dev branch - -- remove external clone of items in `/repositories` -- add **lora oft** support, thanks @antis0007 and @ai-casanova -- **upscalers** - - **compile compile** option, thanks @disty0 - - **chainner** add high quality models from [Helaman](https://openmodeldb.info/users/helaman) - - **chainner** switch to `torchvision.transforms` for all image decode operations -- new option: *settings -> images -> keep incomplete* - can be used to skip vae decode on aborted/skipped/interrupted image generations - - -**Themes** -- all built-in themes are fully supported: - - *black-teal (default), light-teal, black-orange, invoked, amethyst-nightfall, midnight-barbie* -- if you're using any **gradio default** themes or a **3rd party** theme or that are not optimized for SD.Next, you may experience issues - default minimal style has been updated for compatibility, but actual styling is completely outside of SD.Next control +- **Diffusers** + - new model type: [SegMind SSD-1B](https://huggingface.co/segmind/SSD-1B) + its a distilled model, this time 50% smaller and faster version of SD-XL! + test shows batch-size:4 with 1k images used less than 6.5GB of VRAM + download using built-in **Huggingface** downloader: `segmind/SSD-1B` + - new model type: [LCM: Latent Consistency Models](https://github.com/openai/consistency_models) + near-instant generate in a as little as 3 steps! + download using built-in **Huggingface** downloader: `SimianLuo/LCM_Dreamshaper_v7` + - support for **Custom pipelines**, thanks @disty0 + download using built-in **Huggingface** downloader + think of them as plugins for diffusers not unlike original extensions that modify behavior of `ldm` backend + list of community pipelines: + and make sure to check our reference one: `Disty0/zero123plus-pipeline` + which generates 4 output images with different camera positions: front, side, top, back! + - extend support for [Free-U](https://github.com/ChenyangSi/FreeU) + improve generations quality at no cost (other than finding params that work for you) +- **General** + - add **Lora OFT** support, thanks @antis0007 and @ai-casanova + - **Upscalers** + - **compile compile** option, thanks @disty0 + - **chaiNNer** add high quality models from [Helaman](https://openmodeldb.info/users/helaman) + - redesigned **progress bar** with full details on current operation + - new option: *settings -> images -> keep incomplete* + can be used to skip vae decode on aborted/skipped/interrupted image generations + - remove external clone of items in `/repositories` + - switch core font in default theme to **noto-sans** + previously default font was simply *system-ui*, but it lead to too much variations between browsers and platforms +- **Fixes** + - fix **freeu** for backend original and add it to xyz grid + - fix loading diffuser models in huggingface format from non-standard location + - fix default styles looking in wrong location + - fix missing upscaler folder on initial startup + - fix handling of relative path for models + - fix simple live preview device mismatch + - fix batch img2img + - fix diffusers samplers: dpm++ 2m, dpm++ 1s, deis + - fix new style filename template + - fix image name template using model name + - fix image name sequence + - fix model path using relative path + - fix `torch-rocm` and `tensorflow-rocm` version detection, thanks @xangelix + - fix **chainner** upscalers color clipping + - fix for base+refiner workflow in diffusers mode: number of steps, diffuser pipe mode + - fix for prompt encoder with refiner in diffusers mode + - fix prompts-from-file saving incorrect metadata + - fix before-hires step + - fix diffusers switch from invalid model + - **directml** and **ipex** updates + - force second requirements check on startup + - remove lyco, multiple_tqdm + - enhance extension compatibility for exensions directly importing codeformers + - enhance extension compatibility for exensions directly accessing processing params + - css fixes + - clearly mark external themes in ui + - update `openvino`, thanks @disty0 + - update `typing-extensions` ## Update for 2023-10-17 @@ -276,6 +288,11 @@ Upgrades are still possible and supported, but clean install is recommended for see `cli/train.py --help` new support for sd and sdxl, thanks @evshiron new support for full offline mode (without sdnext server running) +- **Themes** + - all built-in themes are fully supported: + - *black-teal (default), light-teal, black-orange, invoked, amethyst-nightfall, midnight-barbie* + - if you're using any **gradio default** themes or a **3rd party** theme or that are not optimized for SD.Next, you may experience issues + default minimal style has been updated for compatibility, but actual styling is completely outside of SD.Next control ## Update for 2023-09-13 diff --git a/extensions-builtin/sd-extension-chainner b/extensions-builtin/sd-extension-chainner index 9d5e6c222..1cdc8578a 160000 --- a/extensions-builtin/sd-extension-chainner +++ b/extensions-builtin/sd-extension-chainner @@ -1 +1 @@ -Subproject commit 9d5e6c22232f8cb850e3603a9ba94781304a912d +Subproject commit 1cdc8578a3c0538177c3ac13721b9764f8782c8f diff --git a/extensions-builtin/sd-webui-agent-scheduler b/extensions-builtin/sd-webui-agent-scheduler index 2e9cdd463..99b2cafbc 160000 --- a/extensions-builtin/sd-webui-agent-scheduler +++ b/extensions-builtin/sd-webui-agent-scheduler @@ -1 +1 @@ -Subproject commit 2e9cdd46358bba6ccad421274dd9375ec9f2d0c6 +Subproject commit 99b2cafbc2b4a2fc93ffcabd56b0ff915396d1f1 diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index 150d6f140..e382d1618 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit 150d6f140d8c8d00add682189c87da09dddb6803 +Subproject commit e382d1618593ae05a7115006de8680d3ddbd9777 diff --git a/modules/images.py b/modules/images.py index 158c613ac..6d0024b2a 100644 --- a/modules/images.py +++ b/modules/images.py @@ -553,11 +553,13 @@ def save_image(image, path, basename = '', seed=None, prompt=None, extension=sha return None, None if not check_grid_size([image]): return None, None - if path is None or len(path) == 0: # set default path to avoid errors when functions are triggered manually or via api and param is not set + if path is None or len(path) == 0: path = shared.opts.outdir_save + + # namegen namegen = FilenameGenerator(p, seed, prompt, image, grid=grid) if shared.opts.save_to_dirs: - dirname = namegen.apply(shared.opts.directories_filename_pattern or "[prompt_words]") + dirname = namegen.apply(shared.opts.directories_filename_pattern or "[date]") path = os.path.join(path, dirname) if forced_filename is None: if short_filename or seed is None: @@ -565,21 +567,9 @@ def save_image(image, path, basename = '', seed=None, prompt=None, extension=sha if shared.opts.samples_filename_pattern and len(shared.opts.samples_filename_pattern) > 0: file_decoration = shared.opts.samples_filename_pattern else: - file_decoration = "[seq]-[prompt_words]" + file_decoration = "[seq]-[model_name]-[prompt_words]" file_decoration = namegen.apply(file_decoration) - file_decoration += suffix - if shared.opts.save_images_add_number: - if '[seq]' not in file_decoration: - file_decoration = f"[seq]-{file_decoration}" - basecount = get_next_sequence_number(path, basename) - filename = None - for i in range(9999): - seq = f"{basecount + i:05}" if basename == '' else f"{basename}-{basecount + i:04}" - filename = os.path.join(path, f"{file_decoration.replace('[seq]', seq)}.{extension}") - if not os.path.exists(filename): - break - else: - filename = os.path.join(path, f"{file_decoration}.{extension}") if basename == '' else os.path.join(path, f"{basename}-{file_decoration}.{extension}") + filename = os.path.join(path, f"{file_decoration}{suffix}.{extension}") if basename is None or basename == '' else os.path.join(path, f"{basename}-{file_decoration}{suffix}.{extension}") else: filename = os.path.join(path, f"{forced_filename}.{extension}") pnginfo = existing_info or {} @@ -589,6 +579,21 @@ def save_image(image, path, basename = '', seed=None, prompt=None, extension=sha params.filename = namegen.sanitize(filename) dirname = os.path.dirname(params.filename) os.makedirs(dirname, exist_ok=True) + + # sequence + if shared.opts.save_images_add_number or '[seq]' in params.filename: + if '[seq]' not in params.filename: + params.filename = f"[seq]-{params.filename}" + basecount = get_next_sequence_number(dirname, basename) + for i in range(9999): + seq = f"{basecount + i:05}" if basename == '' else f"{basename}-{basecount + i:04}" + filename = params.filename.replace('[seq]', seq) + if not os.path.exists(filename): + debug(f'Prompt sequence: input="{params.filename}" seq={seq} output="{filename}"') + params.filename = filename + break + + # callbacks script_callbacks.before_image_saved_callback(params) exifinfo = params.pnginfo.get('UserComment', '') exifinfo = (exifinfo + ', ' if len(exifinfo) > 0 else '') + params.pnginfo.get(pnginfo_section_name, '') From fc7e3c57210d6b3fb440d5a41a23afd7fd41c446 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Thu, 26 Oct 2023 07:09:15 -0400 Subject: [PATCH 2/2] add binary mask --- modules/processing.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/processing.py b/modules/processing.py index 616533987..08be9a3ae 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -72,6 +72,14 @@ def apply_overlay(image, paste_loc, index, overlays): return image +def create_binary_mask(image): + if image.mode == 'RGBA' and image.getextrema()[-1] != (255, 255): + image = image.split()[-1].convert("L").point(lambda x: 255 if x > 128 else 0) + else: + image = image.convert('L') + return image + + def txt2img_image_conditioning(sd_model, x, width, height): if sd_model.model.conditioning_key in {'hybrid', 'concat'}: # Inpainting models # The "masked-image" in this case will just be all zeros since the entire image is masked.