From 38d73e2e517178a0bf0f0380f44312e0f36fc460 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 6 May 2024 17:11:37 -0400 Subject: [PATCH] hyper-sd notes --- CHANGELOG.md | 5 +++- extensions-builtin/Lora/network_overrides.py | 28 ++++++++++++++++++++ extensions-builtin/Lora/networks.py | 14 +++++----- modules/k-diffusion | 2 +- wiki | 2 +- 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 extensions-builtin/Lora/network_overrides.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f13614e4..cda2ed9fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Thanks to @BinaryQuantumSoul for his hard work on this project! Given huge number of changes with *+3443/-3342 commits diff over the past year, a completely different backend/engine and a change of focus, it is time to give credit to original [author](https://github.com/auTOMATIC1111), and move on! -## Update for 2024-05-04 +## Update for 2024-05-06 - **Features**: - **ModernUI** preview of the new [ModernUI](https://github.com/BinaryQuantumSoul/sdnext-modernui) @@ -81,6 +81,9 @@ it is time to give credit to original [author](https://github.com/auTOMATIC1111) sdxs is an extremely fast 1-step generation consistency model that also uses TAESD as quick VAE out-of-the-box to use, simply select from *networks -> models -> SDXS* set parameters: *sampler: CMSI, steps: 1, cfg_scale: 0.0* + - [Hyper-SD](https://huggingface.co/ByteDance/Hyper-SD) + sd15 and sdxl 1-step, 2-step, 4-step and 8-step optimized models using lora + set parameters: *sampler: TCD or LCM, steps: 1/2/4/8, cfg_scale: 0.0* - **Changes**: - Removed built-in extensions: *ControlNet* and *Image-Browser* as both *image-browser* and *controlnet* have native built-in equivalents diff --git a/extensions-builtin/Lora/network_overrides.py b/extensions-builtin/Lora/network_overrides.py new file mode 100644 index 000000000..c8271b431 --- /dev/null +++ b/extensions-builtin/Lora/network_overrides.py @@ -0,0 +1,28 @@ +from modules import shared + + +force_diffusers = [ + 'aaebf6360f7d', # sd15-lcm + '3d18b05e4f56', # sdxl-lcm + 'b71dcb732467', # sdxl-tcd + '813ea5fb1c67', # sdxl-turbo + # not really needed, but just in case + '5a48ac366664', # hyper-sd15-1step + 'ee0ff23dcc42', # hyper-sd15-2step + 'e476eb1da5df', # hyper-sd15-4step + 'ecb844c3f3b0', # hyper-sd15-8step + '1ab289133ebb', # hyper-sd15-8step-cfg + '4f494295edb1', # hyper-sdxl-8step + 'ca14a8c621f8', # hyper-sdxl-8step-cfg + '1c88f7295856', # hyper-sdxl-4step + 'fdd5dcd1d88a', # hyper-sdxl-2step + '8cca3706050b', # hyper-sdxl-1step +] + +def check_override(shorthash): + if len(shorthash) < 4: + return False + force = any([x.startswith(shorthash) for x in force_diffusers]) + if force: + shared.log.debug('LoRA override: force diffusers') + return force diff --git a/extensions-builtin/Lora/networks.py b/extensions-builtin/Lora/networks.py index 5a50964ad..5c4e539ec 100644 --- a/extensions-builtin/Lora/networks.py +++ b/extensions-builtin/Lora/networks.py @@ -13,6 +13,7 @@ import network_lokr import network_full import network_norm import network_glora +import network_overrides import lora_convert import torch import diffusers.models.lora @@ -188,18 +189,15 @@ def load_networks(names, te_multipliers=None, unet_multipliers=None, dyn_dims=No for i, (network_on_disk, name) in enumerate(zip(networks_on_disk, names)): net = None if network_on_disk is not None: + shorthash = getattr(network_on_disk, 'shorthash', '').lower() if debug: - shared.log.debug(f'LoRA load start: name="{name}" file="{network_on_disk.filename}"') + shared.log.debug(f'LoRA load: name="{name}" file="{network_on_disk.filename}" hash="{shorthash}"') try: if recompile_model: shared.compiled_model_state.lora_model.append(f"{name}:{te_multipliers[i] if te_multipliers else 1.0}") - shorthash = getattr(network_on_disk, 'shorthash', '').lower() - if shared.backend == shared.Backend.DIFFUSERS and (shared.opts.lora_force_diffusers # OpenVINO only works with Diffusers LoRa loading. - or shorthash == 'aaebf6360f7d' # sd15-lcm - or shorthash == '3d18b05e4f56' # sdxl-lcm - or shorthash == 'b71dcb732467' # sdxl-tcd - or shorthash == '813ea5fb1c67' # sdxl-turbo - ): + if shared.backend == shared.Backend.DIFFUSERS and shared.opts.lora_force_diffusers: # OpenVINO only works with Diffusers LoRa loading + net = load_diffusers(name, network_on_disk, lora_scale=te_multipliers[i] if te_multipliers else 1.0) + elif shared.backend == shared.Backend.DIFFUSERS and network_overrides.check_override(shorthash): net = load_diffusers(name, network_on_disk, lora_scale=te_multipliers[i] if te_multipliers else 1.0) else: net = load_network(name, network_on_disk) diff --git a/modules/k-diffusion b/modules/k-diffusion index 6ab5146d4..21d12c91a 160000 --- a/modules/k-diffusion +++ b/modules/k-diffusion @@ -1 +1 @@ -Subproject commit 6ab5146d4a5ef63901326489f31f1d8e7dd36b48 +Subproject commit 21d12c91ad4550e8fcf3308ff9fe7116b3f19a08 diff --git a/wiki b/wiki index 9a9539a74..f6d3e5559 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 9a9539a74890789bd06250c830613ad418a2e64b +Subproject commit f6d3e5559eea5e75a8f4d216c116c2eaec0c4e65