Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textual inversion token #9

Open
Junoh-Kang opened this issue Aug 8, 2024 · 1 comment
Open

Textual inversion token #9

Junoh-Kang opened this issue Aug 8, 2024 · 1 comment

Comments

@Junoh-Kang
Copy link

Thank you for your code. How can I visualize prompt with textual inversion tokens?

@wooyeolBaek
Copy link
Owner

wooyeolBaek commented Sep 1, 2024

@Junoh-Kang
Sorry for the late reply. I looked into the examples/textual_inversion in Diffusers and understood that a placeholder token like is used in the prompt, e.g., prompt = "A <cat-toy> backpack". The tokenizer likely splits <cat-toy> into <, cat, -, toy, and >, with an attention map stored for each part. If you want an attention map for the entire <cat-toy> token, you can simply modify the resize_and_save function in utils.py to sum the attention maps for <, cat, -, toy, and > before normalizing them, and save this as the attention map for <cat-toy>. I think this should solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants