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

feat: Perpendicular add #46

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open

feat: Perpendicular add #46

wants to merge 8 commits into from

Conversation

ljleb
Copy link
Collaborator

@ljleb ljleb commented Sep 7, 2023

Perpendicular add:

$$ M = A + \alpha \times ((B - C) + (A - C) \frac{(A - C) \cdot (B - C)}{(A - C) \cdot (A - C)}) $$

model A: https://civitai.com/models/81359?modelVersionId=86337
model B: https://civitai.com/models/108882/ink-prt
model C: SD1.5 base model from runwayml
alpha: 1.0

[image]

@ljleb ljleb changed the base branch from main to dev September 7, 2023 03:58
@ljleb ljleb marked this pull request as ready for review September 7, 2023 05:50
@ljleb

This comment was marked as outdated.

@ljleb
Copy link
Collaborator Author

ljleb commented Sep 8, 2023

I'll open a new PR when I find a good candidate for negative weights clipping.

@ljleb ljleb closed this Sep 8, 2023
@ljleb ljleb reopened this Feb 11, 2024
@ljleb
Copy link
Collaborator Author

ljleb commented Feb 12, 2024

@Clybius (apologies if I got the wrong handle!) came up with a more appropriate approach for the projection part of the formulae, which I just implemented. It seems to work much better on models that have a low cosine similarity from one another. On models that are similar, it resembles a weighted sum. I updated the formulae above in the OP to reflect this.

I tested rebasin with add perpendicular difference and it works really well. Since plain add difference doesn't work with rebasin, I think this method might be a valuable replacement in some cases. It also doesn't need weights clipping to crank alpha up to 1. More tests needed with dj cats I guess.

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.

1 participant