xhinker / sd_embed

Generate long weighted prompt embeddings for Stable Diffusion
Apache License 2.0
85 stars 9 forks source link

Excuse me, I wanted to ask if there is support for textual inversion?, #23

Closed Eduardishion closed 1 month ago

Eduardishion commented 1 month ago

The emphasis assignment works correctly for me, but I had doubts about whether it is possible to apply that emphasis in Textual Inversion (embeddings)

xhinker commented 1 month ago

I haven't tried TI, but I think it should work

Teriks commented 1 month ago

I currently preprocess the positive and negative prompts using.


prompt_text = pipeline.maybe_convert_prompt(prompt_text, tokenizer=pipeline.tokenizer)

This expands any single token that is associated with a TI into multiple tokens that the TI will understand.

you must use which ever tokenizer is going to be used for embedding generation with sd_embed.

Pass this converted prompt with the expanded tokens to sd_embed.

This works okay but is maybe not a perfect solution.

See here for a reference to what I am talking about: https://github.com/Teriks/dgenerate/blob/v4.3.0/dgenerate/promptweighters/sdembedpromptweighter.py

Eduardishion commented 1 month ago

Hello @Teriks I just tried your solution, and it seems like the most appropriate way compared to others that I tried to apply. I did some testing and I liked the results, I'm still testing with style type embeddings. Thank you very much for comparing your solution, and another thank you because for your "dgenerate" repository, I found this incredible library, also thanks to the author of the library @xhinker, it would be incredible if you continue to share this library, I love it.