From affbaf69ace8b14e829ad346f61c29eaee3e1cef Mon Sep 17 00:00:00 2001 From: smthemex <138738845+smthemex@users.noreply.github.com> Date: Sat, 27 Jul 2024 18:00:55 +0800 Subject: [PATCH] Update pipeline.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when enable_model_cpu_offload() clip need cpu,so pipe to --- utils/pipeline.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/pipeline.py b/utils/pipeline.py index b0fd9d8..c7a3e7c 100644 --- a/utils/pipeline.py +++ b/utils/pipeline.py @@ -15,7 +15,8 @@ import diffusers dif_version = str(diffusers.__version__) dif_version_int= int(dif_version.split(".")[1]) if dif_version_int>28: - from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl import StableDiffusionXLPipelineOutput + from diffusers.pipelines.stable_diffusion_xl.pipeline_stable_diffusion_xl import StableDiffusionXLPipelineOutput, \ + rescale_noise_cfg else: from diffusers.pipelines.stable_diffusion_xl import StableDiffusionXLPipelineOutput @@ -118,8 +119,8 @@ class PhotoMakerStableDiffusionXLPipeline(StableDiffusionXLPipeline): # load finetuned CLIP image encoder and fuse module here if it has not been registered to the pipeline yet print(f"Loading PhotoMaker components [1] id_encoder from [{pretrained_model_name_or_path_or_dict}]...") id_encoder = PhotoMakerIDEncoder() - id_encoder.load_state_dict(state_dict["id_encoder"], strict=True) - id_encoder = id_encoder.to(self.device, dtype=self.unet.dtype) + id_encoder.load_state_dict(state_dict["id_encoder"], strict=False) + id_encoder = id_encoder.to("cuda", dtype=self.unet.dtype) self.id_encoder = id_encoder self.id_image_processor = CLIPImageProcessor()