Skip to content

Commit

Permalink
fix after recent comfyui upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
cubiq committed Sep 20, 2024
1 parent 1c1eb14 commit 579bdf6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions InstantID.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ def INPUT_TYPES(s):
CATEGORY = "InstantID"

def apply_instantid(self, instantid, insightface, control_net, image, model, positive, negative, start_at, end_at, weight=.8, ip_weight=None, cn_strength=None, noise=0.35, image_kps=None, mask=None, combine_embeds='average'):
self.dtype = torch.float16 if comfy.model_management.should_use_fp16() else torch.float32
dtype = comfy.model_management.unet_dtype()
if dtype not in [torch.float32, torch.float16, torch.bfloat16]:
dtype = torch.float16 if comfy.model_management.should_use_fp16() else torch.float32

self.dtype = dtype
self.device = comfy.model_management.get_torch_device()

ip_weight = weight if ip_weight is None else ip_weight
Expand Down Expand Up @@ -380,7 +384,7 @@ def apply_instantid(self, instantid, insightface, control_net, image, model, pos

d['control'] = c_net
d['control_apply_to_uncond'] = False
d['cross_attn_controlnet'] = image_prompt_embeds.to(comfy.model_management.intermediate_device()) if is_cond else uncond_image_prompt_embeds.to(comfy.model_management.intermediate_device())
d['cross_attn_controlnet'] = image_prompt_embeds.to(comfy.model_management.intermediate_device(), dtype=c_net.cond_hint_original.dtype) if is_cond else uncond_image_prompt_embeds.to(comfy.model_management.intermediate_device(), dtype=c_net.cond_hint_original.dtype)

if mask is not None and is_cond:
d['mask'] = mask
Expand Down

0 comments on commit 579bdf6

Please sign in to comment.