From c328be9f2775768ce9d2708148dcf3f8d79d463f Mon Sep 17 00:00:00 2001 From: smthemex <138738845+smthemex@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:37:47 +0800 Subject: [PATCH] Update Storydiffusion_node.py --- Storydiffusion_node.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Storydiffusion_node.py b/Storydiffusion_node.py index 6e9ca13..e20ffaf 100644 --- a/Storydiffusion_node.py +++ b/Storydiffusion_node.py @@ -35,6 +35,9 @@ global sa32, sa64 global write global height_s, width_s +import transformers +transformers_v=float(transformers.__version__.rsplit(".",1)[0]) + photomaker_dir=os.path.join(folder_paths.models_dir, "photomaker") device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" @@ -1525,6 +1528,20 @@ class Storydiffusion_Model_Loader: set_attention_processor(pipe.unet, id_length, is_ipadapter=False) elif use_kolor: logging.info("start kolor processing...") + if transformers_v>=4.45: + import shutil + print("transformers_v>=4.45 cause error,try fix it") + chatglm_config_fix = os.path.join(dir_path, "kolors", "tokenization_chatglm.py") + chatglm_config_origin = os.path.join(repo_id, "text_encoder", "tokenization_chatglm.py") + chatglm_config_origin_tokens = os.path.join(repo_id, "tokenizer", "tokenization_chatglm.py") + try: + if os.path.exists(chatglm_config_fix): + shutil.copy2(chatglm_config_fix, chatglm_config_origin) + shutil.copy2(chatglm_config_fix, chatglm_config_origin_tokens) + print(f"replace {chatglm_config_origin_tokens} and{chatglm_config_origin} from {chatglm_config_fix}") + except: + print(f"fix fail,you can copy from {chatglm_config_fix} ,then cover {chatglm_config_origin} and {chatglm_config_origin_tokens}") + pipe=kolor_loader(repo_id, model_type, set_attention_processor, id_length, kolor_face, clip_vision_path, clip_load, CLIPVisionModelWithProjection, CLIPImageProcessor, photomaker_dir, face_ckpt, AutoencoderKL, EulerDiscreteScheduler, UNet2DConditionModel)