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

How to Use Multi-ID #81

Open
GavinZhao19 opened this issue Jan 26, 2024 · 17 comments
Open

How to Use Multi-ID #81

GavinZhao19 opened this issue Jan 26, 2024 · 17 comments

Comments

@GavinZhao19
Copy link

Hello,

I recently came across the Multi-ID feature mentioned in the documentation, but I'm having trouble finding clear examples of how to use it. Specifically, I'm interested in combining images of different individuals, such as uploading two separate photos and generating a composite image.

For instance, I'd like to upload photos of two celebrities, Yang Mi and Taylor Swift, and create a merged image of them. However, I haven't found any examples in the code or on the Hugging Face platform that demonstrate how to achieve this.

Could you please provide some guidance or instructions on how to use the Multi-ID feature for this purpose? Any example code or detailed steps would be greatly appreciated.

Thank you for your assistance.

@ResearcherXman
Copy link
Member

We don't have a specific plan to release this part of codes by now, but we do encourage the community to implement and PR.

@zewolf5
Copy link

zewolf5 commented Jan 26, 2024

Well. Since the answer to having multiple input images is suggested here and works:
#56 (comment)

Not sure if its already there, but multiple reference images? I could not find a way to select more than one image in the sample code provided. Topic #33 mentioned use of multiple reference images for better results.

I'm no expert but this should work image = pipe( ... image_embeds=(face_emb1 + face_emb2 + face_emb3 + face_emb4)/4, ...)

It seems to also work for adding different pictures into the same calculation. Did some quick testing and it seems to be the way to go.

Load the different pictures, either many from only one or multiple people and get a combined "face".
If you have gotten the sample code up and running, you got something like

face_emb = face_info['embedding']
change it to
face_emb = (face_info1['embedding'] + face_info2['embedding']) / 2
or
face_emb = (face_info1['embedding'] + face_info2['embedding'] + face_info3['embedding']) / 3
etc.

I made a function for that taking a folder of face images:
face_embeds = helpers.getAverageFaceEmb(face_folder)

So get 1 face_info object for each image. Add and divide. I myself have not quite read and understood the concepts, but seems to be some math vectors or such that defines what a face looks like. So pure math to add the definition of the faces.

@platform-kit
Copy link

We don't have a specific plan to release this part of codes by now, but we do encourage the community to implement and PR.

Is there a reason you are being vague about it? What do you gain by not releasing the code that you demonstrated in your paper?

@wangqixun
Copy link
Member

We don't have a specific plan to release this part of codes by now, but we do encourage the community to implement and PR.

Is there a reason you are being vague about it? What do you gain by not releasing the code that you demonstrated in your paper?

maybe its name is not OpenAID

@usamaehsan
Copy link

Well. Since the answer to having multiple input images is suggested here and works: #56 (comment)

Not sure if its already there, but multiple reference images? I could not find a way to select more than one image in the sample code provided. Topic #33 mentioned use of multiple reference images for better results.

I'm no expert but this should work image = pipe( ... image_embeds=(face_emb1 + face_emb2 + face_emb3 + face_emb4)/4, ...)

It seems to also work for adding different pictures into the same calculation. Did some quick testing and it seems to be the way to go.

Load the different pictures, either many from only one or multiple people and get a combined "face". If you have gotten the sample code up and running, you got something like

face_emb = face_info['embedding'] change it to face_emb = (face_info1['embedding'] + face_info2['embedding']) / 2 or face_emb = (face_info1['embedding'] + face_info2['embedding'] + face_info3['embedding']) / 3 etc.

I made a function for that taking a folder of face images: face_embeds = helpers.getAverageFaceEmb(face_folder)

So get 1 face_info object for each image. Add and divide. I myself have not quite read and understood the concepts, but seems to be some math vectors or such that defines what a face looks like. So pure math to add the definition of the faces.

@zewolf5 can we use different weight to each image?

@G-force78
Copy link

We don't have a specific plan to release this part of codes by now, but we do encourage the community to implement and PR.

In your original demo on hf you had it implemented. Why was it removed?

@cubiq
Copy link

cubiq commented Feb 11, 2024

It's possible with attention masking

ComfyUI_temp_shjmq_00009_

(this is done in comfyui)

image

https://github.com/cubiq/ComfyUI_InstantID

@Enzzer
Copy link

Enzzer commented Feb 13, 2024

It's possible with attention masking

ComfyUI_temp_shjmq_00009_

(this is done in comfyui)

image

https://github.com/cubiq/ComfyUI_InstantID

Can you please share the workflow you used to do this?

@cubiq
Copy link

cubiq commented Feb 13, 2024

@Enzzer the workflow is in the repository

@Enzzer
Copy link

Enzzer commented Feb 13, 2024

@cubiq Thanks for sharing the workflow!
I tried using it as it is (other than using my face and pose images) but I'm not getting the same results as you.
I'm getting both faces as the last input face image, seems like the first face is lost in the conditioning chain.
Any idea why?

@cubiq
Copy link

cubiq commented Feb 13, 2024

you probably just need to update the extension

@Enzzer
Copy link

Enzzer commented Feb 13, 2024

@cubiq I tried updating both ComfyUI and your extension but I'm still getting the same face twice.
Can you share your input images so I can test with them?

@toonverbeek
Copy link

FWIW, also getting the same result as @Enzzer where both images are merged into one face. @Enzzer did you find a solution by any chance?

@cubiq
Copy link

cubiq commented Feb 21, 2024

the latest version, with the provided workflow works very well.

@toonverbeek
Copy link

Yes confirmed, I used the reference pose image from the repository with two custom portrait photo's and results are now a lot better. Thanks for the update 👍

@xpluscal
Copy link

xpluscal commented Mar 7, 2024

hey @toonverbeek can you share a workflow on how you combined pose with multi ID? How did you achieve this?

@toonverbeek
Copy link

hey @toonverbeek can you share a workflow on how you combined pose with multi ID? How did you achieve this?

I used essentially the default multi-id workflow included in this repository. I kept the pose reference image but replaced the two other inputs with my own images. That worked well enough for my usecase.

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