From 2973ff24c5ba11101c40b58eb1b11b0829c0bdd3 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sat, 28 Jan 2023 00:19:33 -0500 Subject: [PATCH] Round CLIP position ids to fix float issues in some checkpoints. --- comfy/sd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/comfy/sd.py b/comfy/sd.py index 6948fcac3..91db6f4e0 100644 --- a/comfy/sd.py +++ b/comfy/sd.py @@ -32,6 +32,9 @@ def load_model_from_config(config, ckpt, verbose=False, load_state_dict_to=[]): y = x.replace("cond_stage_model.transformer.", "cond_stage_model.transformer.text_model.") sd[y] = sd.pop(x) + if 'cond_stage_model.transformer.text_model.embeddings.position_ids' in sd: + sd['cond_stage_model.transformer.text_model.embeddings.position_ids'] = sd['cond_stage_model.transformer.text_model.embeddings.position_ids'].round() + for x in load_state_dict_to: x.load_state_dict(sd, strict=False)