From 77657611c005ff024af3af02eb21a2c34d544942 Mon Sep 17 00:00:00 2001 From: Disty0 Date: Fri, 21 Jun 2024 19:30:20 +0300 Subject: [PATCH] Fix Diffusers requires_aesthetics_score --- modules/sd_models.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/sd_models.py b/modules/sd_models.py index c4a896de6..7ab95193b 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -1299,10 +1299,19 @@ def switch_pipe(cls: diffusers.DiffusionPipeline, pipeline: diffusers.DiffusionP def set_diffuser_pipe(pipe, new_pipe_type): + n = getattr(pipe.__class__, '__name__', '') + + if new_pipe_type == DiffusersTaskType.TEXT_2_IMAGE and 'StableDiffusionXL' in n and 'requires_aesthetics_score' in pipe.config: + # Diffusers adds requires_aesthetics_score with img2img and complains if requires_aesthetics_score exist in txt2img + internal_dict = dict(pipe._internal_dict) + internal_dict.pop('requires_aesthetics_score', None) + del pipe._internal_dict + pipe.register_to_config(**internal_dict) + if get_diffusers_task(pipe) == new_pipe_type: return pipe + # skip specific pipelines - n = getattr(pipe.__class__, '__name__', '') if n in ['StableDiffusionReferencePipeline', 'StableDiffusionAdapterPipeline', 'AnimateDiffPipeline', 'AnimateDiffSDXLPipeline']: return pipe if 'Onnx' in pipe.__class__.__name__: