Skip to content

Commit

Permalink
allow batches of kps images, fix cubiq#80
Browse files Browse the repository at this point in the history
  • Loading branch information
matt3o committed Mar 5, 2024
1 parent 0fcf494 commit 34dd13c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions InstantID.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def INPUT_TYPES(s):
CATEGORY = "InstantID"

def preprocess_image(self, faceanalysis, image):
face_kps = extractFeatures(faceanalysis, image[0].unsqueeze(0), extract_kps=True)
face_kps = extractFeatures(faceanalysis, image, extract_kps=True)

if face_kps is None:
face_kps = torch.zeros_like(image)
Expand Down Expand Up @@ -437,7 +437,8 @@ def apply_instantid(self, instantid, insightface, control_net, image, model, pos
if face_embed is None:
raise Exception('Reference Image: No face detected.')

face_kps = extractFeatures(insightface, image_kps[0].unsqueeze(0) if image_kps is not None else image[0].unsqueeze(0), extract_kps=True)
# if no keypoints image is provided, use the image itself (only the first one in the batch)
face_kps = extractFeatures(insightface, image_kps if image_kps is not None else image[0].unsqueeze(0), extract_kps=True)

if face_kps is None:
face_kps = torch.zeros_like(image) if image_kps is None else image_kps
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The person is posed based on the keypoints generated from the reference image. Y

## Noise Injection

The default InstantID implementation seems to really burn the image, I find that by injecting noise to the negative embeds we can mitigate the effect and also increase the likeliness to the reference. The default Apply InstantID node automatically injects 35% noise, if you want to fine tune the effect you use the Advanced InstantID node.
The default InstantID implementation seems to really burn the image, I find that by injecting noise to the negative embeds we can mitigate the effect and also increase the likeliness to the reference. The default Apply InstantID node automatically injects 35% noise, if you want to fine tune the effect you can use the Advanced InstantID node.

This is still experimental and may change in the future.

Expand Down

0 comments on commit 34dd13c

Please sign in to comment.