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 IP Adapter weight loading in StableDiffusionXLControlNetInpaintPipeline #7031

Merged
merged 2 commits into from
Feb 19, 2024

Conversation

nkaewam
Copy link
Contributor

@nkaewam nkaewam commented Feb 19, 2024

What does this PR do?

Fixes #6866 and also an extension of PR: #6941

Added IPAdapterMixin loader to StableDiffusionXLControlNetInpaintPipeline to allow for .load_ip_adapter in pipeline.

Example snippet code:

image_encoder = CLIPVisionModelWithProjection.from_pretrained(
            "h94/IP-Adapter",
            subfolder="models/image_encoder",
            torch_dtype=torch.float16,
            cache_dir=CACHE_DIR
).to(device)


pipe = StableDiffusionXLControlNetInpaintPipeline.from_pretrained(
            weight_path,
            cache_dir=CACHE_DIR,
            vae=sd_vae,
            controlnet=controlnet, 
            image_encoder=image_encoder,
            torch_dtype=torch.float16
).to(device)
 
# this PR allows this to be possible      
pipe.load_ip_adapter("h94/IP-Adapter", subfolder="sdxl_models", weight_name="ip-adapter-plus_sdxl_vit-h.safetensors", cache_dir=CACHE_DIR)

images = pipe(
            image=room_image,
            ip_adapter_image=style_image, 
            control_image=control_image, 
            mask_image=mask_image,
            ...other-params
).images

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu
Copy link
Collaborator

oh thanks for the PR!

can you make sure the tests pass? run make style

@nkaewam
Copy link
Contributor Author

nkaewam commented Feb 19, 2024

@yiyixuxu Woops sorry, fixed

@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.

@yiyixuxu yiyixuxu merged commit d8d208a into huggingface:main Feb 19, 2024
13 checks passed
@nkaewam nkaewam changed the title Supper IP Adapter weight loading in StableDiffusionXLControlNetInpaintPipeline Support IP Adapter weight loading in StableDiffusionXLControlNetInpaintPipeline Feb 20, 2024
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.

IP-Adapter support for StableDiffusionXLControlNetInpaintPipeline
3 participants