From 84f343687d2e9346e401b1b9505bbc0fbdcb51b6 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 23 Aug 2023 08:18:40 +0000 Subject: [PATCH] fix python 3.9 compatibility --- modules/prompt_parser_diffusers.py | 4 ++-- modules/sd_models.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/prompt_parser_diffusers.py b/modules/prompt_parser_diffusers.py index f8c2afde8..baf479663 100644 --- a/modules/prompt_parser_diffusers.py +++ b/modules/prompt_parser_diffusers.py @@ -34,7 +34,7 @@ CLIP_SKIP_MAPPING = { def compel_encode_prompts( - pipeline: diffusers.StableDiffusionXLPipeline | diffusers.StableDiffusionPipeline, + pipeline, prompts: list, negative_prompts: list, prompts_2: typing.Optional[list] = None, @@ -67,7 +67,7 @@ def compel_encode_prompts( def compel_encode_prompt( - pipeline: diffusers.StableDiffusionXLPipeline | diffusers.StableDiffusionPipeline, + pipeline, prompt: str, negative_prompt: str, prompt_2: typing.Optional[str] = None, diff --git a/modules/sd_models.py b/modules/sd_models.py index e7adea310..a4b99268e 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -864,10 +864,10 @@ class DiffusersTaskType(Enum): INPAINTING = 3 def set_diffuser_pipe(pipe, new_pipe_type): - sd_checkpoint_info = pipe.sd_checkpoint_info - sd_model_checkpoint = pipe.sd_model_checkpoint - sd_model_hash = pipe.sd_model_hash - has_accelerate = pipe.has_accelerate + sd_checkpoint_info = pipe.sd_checkpoint_info if hasattr(pipe, "sd_checkpoint_info") else None + sd_model_checkpoint = pipe.sd_model_checkpoint if hasattr(pipe, "sd_model_checkpoint") else None + sd_model_hash = pipe.sd_model_hash if hasattr(pipe, "sd_model_hash") else None + has_accelerate = pipe.has_accelerate if hasattr(pipe, "has_accelerate") else None if new_pipe_type == DiffusersTaskType.TEXT_2_IMAGE: new_pipe = diffusers.AutoPipelineForText2Image.from_pipe(pipe) @@ -882,7 +882,6 @@ def set_diffuser_pipe(pipe, new_pipe_type): new_pipe.sd_model_checkpoint = sd_model_checkpoint new_pipe.sd_model_hash = sd_model_hash new_pipe.has_accelerate = has_accelerate - model_data.sd_model = new_pipe shared.log.info(f"Pipeline class changed from {pipe.__class__.__name__} to {new_pipe.__class__.__name__}")