asagi4 / comfyui-prompt-control

ComfyUI nodes for prompt editing and LoRA control
GNU General Public License v3.0
200 stars 16 forks source link

CUT errors with 'not enough values to unpack' #13

Closed UnaiM closed 1 year ago

UnaiM commented 1 year ago

Hi,

I have installed Cutoff and Prompt Control via ComfyUI Manager. When I use a prompt like man with [CUT:green eyes:green] and [CUT:purple hair:purple] on PromptControlSimple, I get the following error:

Error occurred when executing PromptControlSimple:

not enough values to unpack (expected 3, got 2)

File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_aio.py", line 33, in apply
pos_cond = pos_filtered = control_to_clip_common(self, clip, pos_sched, lora_cache, cond_cache)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_clip.py", line 535, in control_to_clip_common
cond = encode(c)
^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_clip.py", line 511, in encode
cond_cache[cachekey] = do_encode(clip, prompt)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_clip.py", line 409, in do_encode
cond, pooled = encode_prompt(clip, prompts[0], style, normalization)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_clip.py", line 254, in encode_prompt
return encode_regions(clip, tokens, regions, style, normalization)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-prompt-control\prompt_control\node_clip.py", line 228, in encode_regions
(r,) = finalize_clip_regions(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Cutoff\cutoff.py", line 217, in finalize_clip_regions
base_embedding_full, pool = encode_from_tokens(clip, base_weighted_tokens, token_normalization, weight_interpretation, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Cutoff\cutoff.py", line 184, in encode_from_tokens
embs_l, _ = advanced_encode_from_tokens(tokenized['l'],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Cutoff\adv_encode.py", line 162, in advanced_encode_from_tokens
tokens = [[t for t,_,_ in x] for x in tokenized]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Cutoff\adv_encode.py", line 162, in
tokens = [[t for t,_,_ in x] for x in tokenized]
^^^^^^^^^^^^^^^^^^
File "C:\Users\Unai\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Cutoff\adv_encode.py", line 162, in
tokens = [[t for t,_,_ in x] for x in tokenized]
^^^^^

If I add another semicolon to the end of each CUT block, it works, but the result isn’t the same as using the Cutoff nodes directly.

Thanks, Unai

asagi4 commented 1 year ago

I can't reproduce this specific error, but it seems there's a problem with the cutoff nodes themselves on recent ComfyUI; the Cutoff Set Regions node thinks the tokens are from an SDXL CLIP model and fails to process them properly. Since I rely on code from the Cutoff nodes, I can't fix this in prompt control.

There have been changes to ComfyUI's token datastructures in the last few days. You can try downgrading your extensions or ComfyUI to earlier versions that worked.

asagi4 commented 1 year ago

This now works for me with the latest ComfyUI Cutoff nodes and ComfyUI commit, so I'm going to close this.

If you still see this error after updating your extensions and ComfyUI, please reopen with an example workflow so I can try to reproduce this.

UnaiM commented 1 year ago

Yep, all good now, thanks for the info! 🎉