automatic
automatic copied to clipboard
[Feature]: Prompt downweighting in original backend
Issue Description
Downweighting is not working as "intended". Weighting a tag with a weight of under 1.0 (tag:0.5) doesnt work as someone would think it does. Downweighted tags still influence the rest of the prompt. Fixing this would improve a ton of prompts because you have more fine control.
A comfyui custom node and invokeai do the downweighting by creating embeddings of every tag and then weight it.
Explanation from the custom node: https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb
The functions are here: https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb/blob/master/adv_encode.py
The best algorithm is comfy++:
if weight_interpretation == "comfy++":
weighted_emb, tokens_down, _ = down_weight(unweighted_tokens, weights, word_ids, base_emb, length, encode_func)
weights = [[w if w > 1.0 else 1.0 for w in x] for x in weights]
#unweighted_tokens = [[(t,1.0) for t, _,_ in x] for x in tokens_down]
embs, pooled = from_masked(unweighted_tokens, weights, word_ids, base_emb, length, encode_func)
weighted_emb += embs
I dont know what the masking is. Probably so that the embeddings don't influence other tags so its weighted correctly? Like blue hair if you weight blue, it still keeps the blue because blue hair is still there?
Version Platform Description
No response
Relevant log output
No response
Backend
Original
Model
SD 1.5
Acknowledgements
- [X] I have read the above and searched for existing issues
- [X] I confirm that this is classified correctly and its not an extension issue