From fa74a0c7fe6bc8cc0dec2d6d4f706f635fbcbdbe Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Fri, 26 Apr 2024 22:22:09 +0200 Subject: [PATCH 1/2] feat: add performance hyper-sd based on 4step LoRA --- modules/async_worker.py | 19 +++++++++++++++++++ modules/config.py | 12 +++++++++++- modules/flags.py | 5 ++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/modules/async_worker.py b/modules/async_worker.py index d8a1e072..a8f857b0 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -263,6 +263,25 @@ def worker(): adm_scaler_negative = 1.0 adm_scaler_end = 0.0 + elif performance_selection == Performance.HYPER_SD: + print('Enter Hyper-SD mode.') + progressbar(async_task, 1, 'Downloading Hyper-SD components ...') + loras += [(modules.config.downloading_sdxl_hyper_sd_lora(), 1.0)] + + if refiner_model_name != 'None': + print(f'Refiner disabled in Hyper-SD mode.') + + refiner_model_name = 'None' + sampler_name = 'ddim' + scheduler_name = 'sgm_uniform' + sharpness = 0.0 + guidance_scale = 1.0 + adaptive_cfg = 1.0 + refiner_switch = 1.0 + adm_scaler_positive = 1.0 + adm_scaler_negative = 1.0 + adm_scaler_end = 0.0 + print(f'[Parameters] Adaptive CFG = {adaptive_cfg}') print(f'[Parameters] Sharpness = {sharpness}') print(f'[Parameters] ControlNet Softness = {controlnet_softness}') diff --git a/modules/config.py b/modules/config.py index b81e218a..e6b66f1c 100644 --- a/modules/config.py +++ b/modules/config.py @@ -539,7 +539,8 @@ wildcard_filenames = [] sdxl_lcm_lora = 'sdxl_lcm_lora.safetensors' sdxl_lightning_lora = 'sdxl_lightning_4step_lora.safetensors' -loras_metadata_remove = [sdxl_lcm_lora, sdxl_lightning_lora] +sdxl_hyper_sd_lora = 'sdxl_hyper_sd_4step_lora.safetensors' +loras_metadata_remove = [sdxl_lcm_lora, sdxl_lightning_lora, sdxl_hyper_sd_lora] def get_model_filenames(folder_paths, extensions=None, name_filter=None): @@ -615,6 +616,15 @@ def downloading_sdxl_lightning_lora(): return sdxl_lightning_lora +def downloading_sdxl_hyper_sd_lora(): + load_file_from_url( + url='https://huggingface.co/ByteDance/Hyper-SD/resolve/main/Hyper-SDXL-4steps-lora.safetensors', + model_dir=paths_loras[0], + file_name=sdxl_hyper_sd_lora + ) + return sdxl_hyper_sd_lora + + def downloading_controlnet_canny(): load_file_from_url( url='https://huggingface.co/lllyasviel/misc/resolve/main/control-lora-canny-rank128.safetensors', diff --git a/modules/flags.py b/modules/flags.py index c9d13fd8..3dc7a021 100644 --- a/modules/flags.py +++ b/modules/flags.py @@ -107,6 +107,7 @@ class Steps(IntEnum): SPEED = 30 EXTREME_SPEED = 8 LIGHTNING = 4 + HYPER_SD = 4 class StepsUOV(IntEnum): @@ -114,6 +115,7 @@ class StepsUOV(IntEnum): SPEED = 18 EXTREME_SPEED = 8 LIGHTNING = 4 + HYPER_SD = 4 class Performance(Enum): @@ -121,6 +123,7 @@ class Performance(Enum): SPEED = 'Speed' EXTREME_SPEED = 'Extreme Speed' LIGHTNING = 'Lightning' + HYPER_SD = 'Hyper-SD' @classmethod def list(cls) -> list: @@ -130,7 +133,7 @@ class Performance(Enum): def has_restricted_features(cls, x) -> bool: if isinstance(x, Performance): x = x.value - return x in [cls.EXTREME_SPEED.value, cls.LIGHTNING.value] + return x in [cls.EXTREME_SPEED.value, cls.LIGHTNING.value, cls.HYPER_SD.value] def steps(self) -> int | None: return Steps[self.name].value if Steps[self.name] else None From 27df5df20bee3c9e2c5e30f59334462bf741a8af Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Tue, 30 Apr 2024 15:06:33 +0200 Subject: [PATCH 2/2] feat: use LoRA weight 0.8, sampler dpmpp_sde_gpu and scheduler_name karras suggested in https://github.com/lllyasviel/Fooocus/discussions/2813#discussioncomment-9245251 results see https://github.com/lllyasviel/Fooocus/discussions/2813#discussioncomment-9275251 --- modules/async_worker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/async_worker.py b/modules/async_worker.py index a8f857b0..a549a5a3 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -266,14 +266,14 @@ def worker(): elif performance_selection == Performance.HYPER_SD: print('Enter Hyper-SD mode.') progressbar(async_task, 1, 'Downloading Hyper-SD components ...') - loras += [(modules.config.downloading_sdxl_hyper_sd_lora(), 1.0)] + loras += [(modules.config.downloading_sdxl_hyper_sd_lora(), 0.8)] if refiner_model_name != 'None': print(f'Refiner disabled in Hyper-SD mode.') refiner_model_name = 'None' - sampler_name = 'ddim' - scheduler_name = 'sgm_uniform' + sampler_name = 'dpmpp_sde_gpu' + scheduler_name = 'karras' sharpness = 0.0 guidance_scale = 1.0 adaptive_cfg = 1.0