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

Error attempting to use with IP Adapter #51

Open
bent1e opened this issue Jan 24, 2024 · 4 comments
Open

Error attempting to use with IP Adapter #51

bent1e opened this issue Jan 24, 2024 · 4 comments

Comments

@bent1e
Copy link

bent1e commented Jan 24, 2024

I tried to join IPA as an image control, but the following issue occurred and I am not sure if my usage is correct.

code:
ipa_model_path = f'/ipa_models'
device = "cuda"
face_adapter = f'InstantIDmodel/ip-adapter.bin'
controlnet_path = f'InstantIDmodel/ControlNetModel'
controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
"modelscope/YamerMIX_v8", controlnet=controlnet, torch_dtype=torch.float16
)
pipe.load_ip_adapter_instantid(face_adapter)
pipe.load_ip_adapter(ipa_model_path, subfolder="models", weight_name="ip-adapter-plus_sdxl_vit-h.bin")
pipe.cuda()
pipe.set_ip_adapter_scale(0.8)
ip_image = Image.open("ref.png")
ip_image.resize((512, 512))
images = pipe(
prompt="a woman",
negative_prompt=None,ip_adapter_image=ip_image,
image_embeds=face_emb,
image=face_kps,width=width, height=height,
controlnet_conditioning_scale=0.8,
num_inference_steps=num_inference_steps,
guidance_scale=5,
).images

Error:
ValueError: <class 'diffusers.models.unet_2d_condition.UNet2DConditionModel'> has the config param encoder_hid_dim_type set to 'ip_image_proj' which requires the keyword argument image_embeds to be passed in added_conditions

@ResearcherXman
Copy link
Member

For now, our pipeline is not fully compatible with IPAdapterMixin in diffusers. In shorts, we rewrite some functions in pipeline_controlnet_sd_xl.py to load InstantID. We are working on it and planning to integrate into diffusers recently.

@bent1e
Copy link
Author

bent1e commented Jan 24, 2024

How should I modify the code to make it effective? Or do you have a specific time plan?

@ResearcherXman
Copy link
Member

If you just want to make IP-Adapter works, you can refer to pipeline and attention files, and add another K,V for IP-Adapter.

@usamaehsan
Copy link

can we use Ip adapter using latest pipeline?

i want to use ip adapter to get reference of body and clothes.

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

No branches or pull requests

3 participants