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

Multi-image masking for single IP Adapter #7499

Merged
merged 12 commits into from
Apr 9, 2024

Conversation

fabiorigano
Copy link
Contributor

What does this PR do?

Image masking is currently supported by passing a mask and an image for each IP Adapter in the pipeline.

This PR extends this usage by allowing multiple masks and images to be passed to a single IP Adapter. Scales must be passed accordingly.

Discussed in #7419

@sayakpaul @yiyixuxu

@fabiorigano fabiorigano changed the title [WIP] Multi-image support for single IP Adapter [WIP] Multi-image masking for single IP Adapter Mar 27, 2024
Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looking nice ❤️ Great work as always. Let's add a fast test and see how it goes?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@fabiorigano
Copy link
Contributor Author

thank you @sayakpaul

ready

@fabiorigano fabiorigano changed the title [WIP] Multi-image masking for single IP Adapter Multi-image masking for single IP Adapter Mar 31, 2024
@@ -544,3 +544,33 @@ def test_ip_adapter_multiple_masks(self):

max_diff = numpy_cosine_similarity_distance(image_slice, expected_slice)
assert max_diff < 5e-4

def test_ip_adapter_multiple_masks_one_adapter(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slow test. I was wondering if it's possible to add a fast test like

def test_ip_adapter_single(self, expected_max_diff: float = 1e-4, expected_pipe_slice=None):

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I missed that

I'll add it now

@DN6 DN6 requested a review from yiyixuxu April 1, 2024 07:21
Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for working on this!
looks good. I left some feedbacks. let's make very clear what's the expected shape for ip_adapter_mask and scale

src/diffusers/models/attention_processor.py Show resolved Hide resolved
src/diffusers/models/attention_processor.py Outdated Show resolved Hide resolved
src/diffusers/models/attention_processor.py Outdated Show resolved Hide resolved
src/diffusers/models/attention_processor.py Outdated Show resolved Hide resolved
@fabiorigano
Copy link
Contributor Author

@yiyixuxu @sayakpaul now it's ready
thanks for your reviews

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!
I will run slow tests to make sure it does not break anything before merge

@yiyixuxu yiyixuxu self-assigned this Apr 8, 2024
@yiyixuxu yiyixuxu mentioned this pull request Apr 8, 2024
@fabiorigano
Copy link
Contributor Author

thank you YiYi!

I fixed the fast test for the panorama pipeline that was failing and the slow test

I ran all the slow tests related to image masking locally and they didn't break :)

@yiyixuxu yiyixuxu merged commit a0cf607 into huggingface:main Apr 9, 2024
15 checks passed
@fabiorigano fabiorigano deleted the multiimageipmask branch April 9, 2024 19:21
XSE42 added a commit to XSE42/diffusers3d that referenced this pull request Apr 30, 2024
diffusers commit a0cf607
    Multi-image masking for single IP Adapter
    (huggingface/diffusers#7499)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants