Fix Diffusers requires_aesthetics_score

This commit is contained in:
Disty0
2024-06-21 19:30:20 +03:00
parent 8eb26b202c
commit 77657611c0
+10 -1
View File
@@ -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__: