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

[Bug] Multiple IP-Adapters apply order #2469

Closed
huchenlei opened this issue Jan 15, 2024 · 2 comments · Fixed by #2470
Closed

[Bug] Multiple IP-Adapters apply order #2469

huchenlei opened this issue Jan 15, 2024 · 2 comments · Fixed by #2470
Assignees
Labels
bug Something isn't working

Comments

@huchenlei
Copy link
Collaborator

#2245 requests multiple images for single IP-Adapter unit because multiple IP-Adapter units do not seem to work together.

Reproduction:

Following 2 setups use exact IP-Adapter units but in different orders, and give totally different results.

Setup1

Unit 0:
1705285714569

Unit 1:
1705285741967

Result:
image

Despite unit 1 having very low weight, the result still mostly look like unit1 (A tiger)

Setup2

Unit 1:
1705285741967

Unit 2:
1705285831030

Result:
image

Result mostly look like unit2, and obviously the weight is too much.

Using only unit 0 (girl) weight = 1

image

Using only unit 1 (tiger) weight = 0.3

image

There is definitely something going wrong with how multiple IP-Adapters are applied.

@huchenlei huchenlei added the bug Something isn't working label Jan 15, 2024
@huchenlei huchenlei self-assigned this Jan 15, 2024
@huchenlei
Copy link
Collaborator Author

After some debug, it seems like only the last unit of IPAdapter get applied, and it get applied twice when 2 units are enabled. This is reasonable as tiger (weight = 0.3) applied twice gives a tiger result, but girl (weight = 1) applied twice gives a over saturated girl result.

@huchenlei
Copy link
Collaborator Author

Fix:

    @staticmethod
    def load_control_model(p, unet, model):
        # ip-adapter model contains embedding data, so each model is unique.
        if 'ip-adapter' not in model and model in Script.model_cache:
            logger.info(f"Loading model from cache: {model}")
            return Script.model_cache[model]

Previously, it was assumed that model only contains state_dict loaded from model file. However, ip-adapter model also contains input image embedding, weight, and many values, so should not be cached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant