From eee815ec99c8ff69d9b31b9eba096442119cb3f8 Mon Sep 17 00:00:00 2001 From: Mario Klingemann Date: Wed, 19 Jun 2024 22:42:41 +0200 Subject: [PATCH] Update sd1_clip.py (#3684) Made token instance check more flexible so it also works with integers from numpy arrays or long tensors --- comfy/sd1_clip.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/comfy/sd1_clip.py b/comfy/sd1_clip.py index 911af0a7..78e556b5 100644 --- a/comfy/sd1_clip.py +++ b/comfy/sd1_clip.py @@ -9,6 +9,7 @@ from . import model_management import comfy.clip_model import json import logging +import numbers def gen_empty_tokens(special_tokens, length): start_token = special_tokens.get("start", None) @@ -130,10 +131,10 @@ class SDClipModel(torch.nn.Module, ClipTokenWeightEncoder): for x in tokens: tokens_temp = [] for y in x: - if isinstance(y, int): + if isinstance(y, numbers.Integral): if y == token_dict_size: #EOS token y = -1 - tokens_temp += [y] + tokens_temp += [int(y)] else: if y.shape[0] == current_embeds.weight.shape[1]: embedding_weights += [y]