diff --git a/__pycache__/efficiency_nodes.cpython-312.pyc b/__pycache__/efficiency_nodes.cpython-312.pyc new file mode 100644 index 0000000..cd30191 Binary files /dev/null and b/__pycache__/efficiency_nodes.cpython-312.pyc differ diff --git a/efficiency_nodes.py b/efficiency_nodes.py index 286d84d..803fa28 100644 --- a/efficiency_nodes.py +++ b/efficiency_nodes.py @@ -72,6 +72,12 @@ def encode_prompts(positive_prompt, negative_prompt, token_normalization, weight refiner_clip, refiner_clip_skip, ascore, is_sdxl, empty_latent_width, empty_latent_height, return_type="both"): + # Ensure prompts are valid strings to prevent tokenization errors + if positive_prompt is None or (isinstance(positive_prompt, str) and not positive_prompt.strip()): + positive_prompt = " " + if negative_prompt is None or (isinstance(negative_prompt, str) and not negative_prompt.strip()): + negative_prompt = " " + positive_encoded = negative_encoded = refiner_positive_encoded = refiner_negative_encoded = None # Process base encodings if needed diff --git a/py/__pycache__/bnk_adv_encode.cpython-312.pyc b/py/__pycache__/bnk_adv_encode.cpython-312.pyc new file mode 100644 index 0000000..7c2df6c Binary files /dev/null and b/py/__pycache__/bnk_adv_encode.cpython-312.pyc differ diff --git a/py/bnk_adv_encode.py b/py/bnk_adv_encode.py index b3d251f..9b2e001 100644 --- a/py/bnk_adv_encode.py +++ b/py/bnk_adv_encode.py @@ -237,6 +237,9 @@ def prepareXL(embs_l, embs_g, pooled, clip_balance): return embs_g, pooled def advanced_encode(clip, text, token_normalization, weight_interpretation, w_max=1.0, clip_balance=.5, apply_to_pooled=True): + # Ensure text is a valid string to prevent tokenization errors + if text is None or (isinstance(text, str) and not text.strip()): + text = " " tokenized = clip.tokenize(text, return_word_ids=True) if isinstance(clip.cond_stage_model, (SDXLClipModel, SDXLRefinerClipModel, SDXLClipG)): embs_l = None @@ -265,6 +268,11 @@ def advanced_encode(clip, text, token_normalization, weight_interpretation, w_ma lambda x: (clip.encode_from_tokens({'l': x}), None), w_max=w_max) def advanced_encode_XL(clip, text1, text2, token_normalization, weight_interpretation, w_max=1.0, clip_balance=.5, apply_to_pooled=True): + # Ensure texts are valid strings to prevent tokenization errors + if text1 is None or (isinstance(text1, str) and not text1.strip()): + text1 = " " + if text2 is None or (isinstance(text2, str) and not text2.strip()): + text2 = " " tokenized1 = clip.tokenize(text1, return_word_ids=True) tokenized2 = clip.tokenize(text2, return_word_ids=True)