Uh oh!
There was an error while loading. Please reload this page.
SD3 IP-Adapter runtime checkpoint conversion - #10718
Merged
Merged
Conversation
guiyrt
commented
Feb 5, 2025
ContributorAuthor
Example output: Inference codeimportosimporttorchfrompathlibimportPathfromdiffusersimportStableDiffusion3Pipelinefromdiffusers.utilsimportload_imagefromtransformersimportSiglipVisionModel, SiglipImageProcessormodel_id="stabilityai/stable-diffusion-3.5-large"image_encoder_id="google/siglip-so400m-patch14-384"ip_adapter_id="InstantX/SD3.5-Large-IP-Adapter"feature_extractor=SiglipImageProcessor.from_pretrained(
image_encoder_id, torch_dtype=torch.bfloat16
)
image_encoder=SiglipVisionModel.from_pretrained(
image_encoder_id, torch_dtype=torch.bfloat16
)
pipe=StableDiffusion3Pipeline.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
feature_extractor=feature_extractor,
image_encoder=image_encoder,
)
# Load IP Adapterpipe.load_ip_adapter(ip_adapter_id, "ip-adapter.bin")
pipe.set_ip_adapter_scale(0.5)
pipe._exclude_from_cpu_offload.append("image_encoder")
pipe.enable_sequential_cpu_offload()
# Inputip_adapter_img=load_image("astronaut.jpg")
# please note that SD3.5 Large is sensitive to highres generation like 1536x1536image=pipe(
width=1024,
height=1024,
prompt="an astronaut on top of a waffle",
negative_prompt="lowres, low quality, worst quality",
num_images_per_prompt=1,
generator=torch.manual_seed(42),
ip_adapter_image=ip_adapter_img,
guidance_scale=6,
num_inference_steps=24,
).images[0]
image.save("result.jpg")Prompt: "an astronaut on top of a waffle" |
HuggingFaceDocBuilderDev
commented
Feb 5, 2025
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. |
guiyrt
commented
Feb 5, 2025
ContributorAuthor
Done and done, thanks for the review @hlky ! |
guiyrt
commented
Feb 13, 2025
ContributorAuthor
Updated PR accounting for #10728 |
shethaadit
approved these changes
Feb 19, 2025
yiyixuxu
commented
Feb 20, 2025
Collaborator
thanks a lot everyone!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What does this PR do?
Fixes#9966.
Now IP-Adapter from InstantX/SD3.5-Large-IP-Adapter can be used directly, with checkpoint runtime conversion.
I also changed the structure to have the familiar
_convert_ip_adapter_attn_to_diffusersand_convert_ip_adapter_image_proj_to_diffusersfunctions.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@hlky@yiyixuxu