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

IP-Adapter face id #2434

Merged
merged 10 commits into from
Jan 10, 2024
Merged

IP-Adapter face id #2434

merged 10 commits into from
Jan 10, 2024

Conversation

huchenlei
Copy link
Collaborator

@huchenlei huchenlei commented Jan 8, 2024

Installation of insightface

FaceID requires insightface, you need to install them in your A1111 venv. Check this ComfyUI issue for help.

In summary, building insightface from source requies compiling some C++ code, which in principle should be avoided at all cost in this repository. See #1875. The workaround this PR has is downloading the pre-build wheel for the largest user group (Windows amd64 users). Other users will need build from source by running pip install insightface.

Models

The following table shows the combination of checkpoint and preprocessor to use for each FaceID IPAdapter Model. Any Tensor size mismatch you may get it is likely caused by a wrong combination.

SD v. IPadapter Preprocessor LoRA
v1.5 FaceID ip-adapter_face_id FaceID LoRA
v1.5 FaceID Plus ip-adapter_face_id_plus FaceID Plus LoRA
v1.5 FaceID Plus v2 ip-adapter_face_id_plus FaceID Plus v2 LoRA
SDXL FaceID ip-adapter_face_id FaceID SDXL LoRA

It is recommended to load the corresponding LoRA when generating with a weight of 0.5 ~ 0.7.

How to use

Step1: Load LoRA

1704766278485

Step2: Configure ControlNet. Choose preprocessor and model.

1704766330081

Step3: Generate

Face input:
image
Output:
image

TODO

  • face_id support
  • face_id_plus support
  • install script for insightface lib
  • verify existing IP-adapters are not broken

Next Steps

  • Automatically apply corresponding LoRA
  • Unload insightface model. (Is that necessary? We already run insightface on CPU)
  • Documentation on IPAdapter usage
  • Automatically pick preprocessor/model when one is selected

@t00350320
Copy link

t00350320 commented Jan 8, 2024

Hi, I have tested your latest branch, but got this error while ip-adapter-faceid_sd15[0a1757e9] loaded:

Missing key(s) in state_dict: "perceiver_resampler.proj_in.weight", "perceiver_resampler.proj_in.bias", "perceiver_resampler.proj_out.weight", "perceiver_resampler.proj_out.bias", "perceiver_resampler.norm_out.weight", "perceiver_resampler.norm_out.bias", "perceiver_resampler.layers.0.0.norm1.weight", "perceiver_resampler.layers.0.0.norm1.bias", "perceiver_resampler.layers.0.0.norm2.weight", "perceiver_resampler.layers.0.0.norm2.bias", "perceiver_resampler.layers.0.0.to_q.weight", "perceiver_resampler.layers.0.0.to_kv.weight", "perceiver_resampler.layers.0.0.to_out.weight", "perceiver_resampler.layers.0.1.0.weight", "perceiver_resampler.layers.0.1.0.bias", "perceiver_resampler.layers.0.1.1.weight", "perceiver_resampler.layers.0.1.3.weight", "perceiver_resampler.layers.1.0.norm1.weight", "perceiver_resampler.layers.1.0.norm1.bias", "perceiver_resampler.layers.1.0.norm2.weight", "perceiver_resampler.layers.1.0.norm2.bias", "perceiver_resampler.layers.1.0.to_q.weight", "perceiver_resampler.layers.1.0.to_kv.weight", "perceiver_resampler.layers.1.0.to_out.weight", "perceiver_resampler.layers.1.1.0.weight", "perceiver_resampler.layers.1.1.0.bias", "perceiver_resampler.layers.1.1.1.weight", "perceiver_resampler.layers.1.1.3.weight", "perceiver_resampler.layers.2.0.norm1.weight", "perceiver_resampler.layers.2.0.norm1.bias", "perceiver_resampler.layers.2.0.norm2.weight", "perceiver_resampler.layers.2.0.norm2.bias", "perceiver_resampler.layers.2.0.to_q.weight", "perceiver_resampler.layers.2.0.to_kv.weight", "perceiver_resampler.layers.2.0.to_out.weight", "perceiver_resampler.layers.2.1.0.weight", "perceiver_resampler.layers.2.1.0.bias", "perceiver_resampler.layers.2.1.1.weight", "perceiver_resampler.layers.2.1.3.weight", "perceiver_resampler.layers.3.0.norm1.weight", "perceiver_resampler.layers.3.0.norm1.bias", "perceiver_resampler.layers.3.0.norm2.weight", "perceiver_resampler.layers.3.0.norm2.bias", "perceiver_resampler.layers.3.0.to_q.weight", "perceiver_resampler.layers.3.0.to_kv.weight", "perceiver_resampler.layers.3.0.to_out.weight", "perceiver_resampler.layers.3.1.0.weight", "perceiver_resampler.layers.3.1.0.bias", "perceiver_resampler.layers.3.1.1.weight", "perceiver_resampler.layers.3.1.3.weight".

PTAL!!! Thank you!

@huchenlei
Copy link
Collaborator Author

It's still WIP. I will flip it to ready-to-review once everything is ready.

@huchenlei
Copy link
Collaborator Author

face_id working now. face_id_plus still WIP.

@huchenlei huchenlei requested a review from sdbds January 8, 2024 22:34
@huchenlei huchenlei marked this pull request as ready for review January 8, 2024 22:34
@huchenlei
Copy link
Collaborator Author

@sdbds I think the implementation is mostly done. I decide to not including the insightface lib source code here as in previous PR there was some issues with running insightface from source. This PR includes an install script that fetches the pre-build wheel for windows arm64 users, but for all other users, they need to manually install insightface package. There are already sufficient discussions here about insightface installation: cubiq/ComfyUI_IPAdapter_plus#162

@sdbds
Copy link
Collaborator

sdbds commented Jan 9, 2024

@sdbds I think the implementation is mostly done. I decide to not including the insightface lib source code here as in previous PR there was some issues with running insightface from source. This PR includes an install script that fetches the pre-build wheel for windows arm64 users, but for all other users, they need to manually install insightface package. There are already sufficient discussions here about insightface installation: cubiq/ComfyUI_IPAdapter_plus#162

Thanks for the swift work! I will test it afterward. I noticed earlier when I found the onnx dependency that it seemed like the source code was more of a pain.

@vidosiki43
Copy link

Hello. Can you please tell me how to set preprocessor IP-Adapter face id? I have updated sd-webui-controlnet, but I don't have this preprocessor
295081734-93fe6c42-8dd2-4a0a-82b0-112d8dd61ce2
111

@huchenlei
Copy link
Collaborator Author

The PR has not been merged yet. You need to checkout the PR manually to use faceid or wait the PR to be merged.

scripts/processor.py Outdated Show resolved Hide resolved
@huchenlei
Copy link
Collaborator Author

@sdbds Gentle ping on the review.

Copy link
Collaborator

@sdbds sdbds left a comment

Choose a reason for hiding this comment

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

LGTM.
Tested in linux with Face sd15 and Face plus
image

image

@aMoonshine
Copy link

where to get preprocessor for faceID? or how to make it preprocessor, not a model if it's just another model there?
image

@huchenlei huchenlei merged commit a846376 into Mikubill:main Jan 10, 2024
1 check passed
@imfog
Copy link

imfog commented Jan 18, 2024

Hello. Can you please tell me how to set preprocessor IP-Adapter face id? I have updated sd-webui-controlnet, but I don't have this preprocessor 295081734-93fe6c42-8dd2-4a0a-82b0-112d8dd61ce2 111

need insightFace
https://github.com/deepinsight/insightface

@identify86
Copy link

please add FaceId portrait to webui A1111,THX!!!!!!!!!!!!!!!!!!!!!!

@huchenlei
Copy link
Collaborator Author

please add FaceId portrait to webui A1111,THX!!!!!!!!!!!!!!!!!!!!!!

it's already added several days ago: #2530

@identify86
Copy link

identify86 commented Jan 24, 2024 via email

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.

None yet

7 participants