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

support for ckpt inversions #209

Merged
merged 2 commits into from
Mar 3, 2023
Merged

support for ckpt inversions #209

merged 2 commits into from
Mar 3, 2023

Conversation

ssube
Copy link
Owner

@ssube ssube commented Mar 3, 2023

Add support for ckpt textual inversions with multiple vectors.

The https://huggingface.co/sd-concepts-library inversions have a single layer:

>>> t2["<jungle-punk>"].shape
torch.Size([768])

While most of the inversions/embeddings on Civitai have more than one:

>>> t = torch.load("autumn.ckpt")
>>> t["string_to_param"]["*"].shape
torch.Size([5, 768])
>>> t = torch.load("ghostly.ckpt")
>>> t["string_to_param"]["*"].shape
torch.Size([10, 768])

By generating a token for each [768] vector in the ckpt, it's possible to embed them in an ONNX model and control each layer's strength separately (using LPW or by giving the token more than once).

ghostly-0, ghostly-1, ghostly-2, ghostly-3, ghostly-4, ghostly-5, ghostly-6, ghostly-7, ghostly-8, ghostly-9, ghostly-0, ghostly-1, ghostly-2, ghostly-3, ghostly-4, ghostly-5, ghostly-6, ghostly-7, ghostly-8, ghostly-9, ...
autumn-0, autumn-1, autumn-2, autumn-3, autumn-4, autumn-0, autumn-1, autumn-2, autumn-3, autumn-4,

The only real disadvantage is needing to use more than one token, as far as I can tell.

@sonarcloud
Copy link

sonarcloud bot commented Mar 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ssube ssube merged commit 22e9d54 into main Mar 3, 2023
@ssube ssube added this to the v0.8 milestone Mar 5, 2023
@ssube ssube mentioned this pull request Mar 5, 2023
99 tasks
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

Successfully merging this pull request may close these issues.

None yet

1 participant