Add prompt weights to the txt2img script#580
Add prompt weights to the txt2img script#580tijszwinkels wants to merge 2 commits intoCompVis:mainfrom
Conversation
|
Testing this it seems to be working so far. Results below That would be the trifecta for my setup. |
|
Although this does also work on img2img - if you set the values too high, it can destroy the image |
|
These weights are to be used with subtlety. I'd say anywhere between 0.5-1.3 is fine, but if too many subprompts are being pushed too much out of whack, it will basically push the embedding vector beyond what the model was trained on and corruption will occur. |
Hey, Thanks for trying this out! See my above message about not stretching these values too much. |
|
Trying to get it to work with negative prompts as well over here: https://github.com/tijszwinkels/stable-diffusion/tree/prompt-weight-negative You can give it a whirl if you want. |
|
Can confirm the weighted prompts work well. ControlNet uses a variation of the cond / uncond lines: |
|
Perhaps have a look here: The nataili lib uses prompt weights borrowed from this implementation (As a matter of fact; I wrote this implementation because I wanted prompt weights for stable horde, which uses this lib) - and it support controlnet as well now. |
BTW; using the get_learned_conditioning_with_prompt_weights on an array of prompts goes something like this: (with 'prompts' being the array). |
|
Sorry to bug you again - still having trouble getting weighted prompts into my controlnet implementation. I tried copying the basic version from the img2img example - hoping it would at least get me part of the way- but I am still getting weird errors. Right now this is erroring out on |



I've been looking for a good code example to add prompt weights, but most implementations I found just split the prompt in subprompts, and make a weighted average of the embeddings of these subprompts. This has two disadvantages:
This implementation takes a different approach; It calculates the difference between the whole prompt with and without the weighted subprompt. It takes this difference to be the contribution of the subprompt to the embedding vector, and uses this to subtly modify the original embedding vector on the weight. Results seem much more stable (small tweaks don't disturb the entire result), and I believe this to be a better method.
Tell me if I'm doing it wrong. :)