asagi4 / comfyui-prompt-control

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

[BUG] Weighting after some BREAKs is broken with comfy++ clip encoding #51

Open Happ1ness-dev opened 1 week ago

Happ1ness-dev commented 1 week ago

Hello, I've found a pretty weird bug(?) when using comfy++ in STYLE(). Weighting in some BREAKs seems to be getting ignored when used with comfy++ clip encoding, for some reason.

To Reproduce: Try something like this: STYLE(comfy++) A dog BREAK (a cat:1) BREAK (a snake:9). The output should be all artifacts, but it's not. It doesn't change no matter what you put in place of a snake and no matter the weight. comfy, A1111 and compel all work fine.

Expected behavior: Process all tokens properly and not ignore the weighting after some BREAKs.

asagi4 commented 1 week ago

I think this might be a bug/feature with the Advanced CLIP encoding nodes, since all my code does is call its functions. What BREAK does is it calls clip.tokenize() on each text chunk, then joins the chunks together to create a single set of tokens, and then passes it into the encoding function.

Happ1ness-dev commented 1 week ago

might be a bug/feature with the Advanced CLIP encoding nodes

Could be, but it happens only when I use BREAK, and it also seems to happen very randomly. In simple prompts like this, the last (second) BREAK seems to be affected, while in lengthy prompts, the first BREAK is affected. In both cases, I used only 2 BREAKs.

Happ1ness-dev commented 1 week ago

It's almost as if I'm crossing some token threshold 🤔 But that one is just a guess.

asagi4 commented 1 week ago

BREAK always pads the chunk to whatever the maximum for one chunk is (I think it was 75 or something), so you should hit this bug without breaks if your prompt exceeds that chunk size times whatever maximum number of chunks the code can handle.