fix: support updated ComfyUI IPAdapter Plus
This commit is contained in:
@@ -7,6 +7,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
|
||||
|
||||
|
||||
## NOTICE
|
||||
* V4.85: Incompatible with the outdated **ComfyUI IPAdapter Plus**. (A version dated March 24th or later is required.)
|
||||
* V4.77: Compatibility patch applied. Requires ComfyUI version (Oct. 8th) or later.
|
||||
* V4.73.3: ControlNetApply (SEGS) supports AnimateDiff
|
||||
* V4.20.1: Due to the feature update in `RegionalSampler`, the parameter order has changed, causing malfunctions in previously created `RegionalSamplers`. Please adjust the parameters accordingly.
|
||||
|
||||
@@ -2,7 +2,7 @@ import configparser
|
||||
import os
|
||||
|
||||
|
||||
version_code = [4, 84]
|
||||
version_code = [4, 85]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 20
|
||||
|
||||
+11
-7
@@ -1505,7 +1505,7 @@ class PixelKSampleUpscaler:
|
||||
|
||||
|
||||
class IPAdapterWrapper:
|
||||
def __init__(self, ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, reference_image, prev_control_net=None):
|
||||
def __init__(self, ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, reference_image, prev_control_net=None, combine_embeds='concat'):
|
||||
self.reference_image = reference_image
|
||||
self.ipadapter_pipe = ipadapter_pipe
|
||||
self.weight = weight
|
||||
@@ -1518,18 +1518,22 @@ class IPAdapterWrapper:
|
||||
self.faceid_v2 = faceid_v2
|
||||
self.weight_v2 = weight_v2
|
||||
self.image = reference_image
|
||||
self.combine_embeds = combine_embeds
|
||||
|
||||
# name 'apply_ipadapter' isn't allowed
|
||||
def doit_ipadapter(self, model):
|
||||
cnet_image_list = [self.image]
|
||||
prev_cnet_images = []
|
||||
|
||||
if 'IPAdapterApply' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
if 'IPAdapterAdvanced' not in nodes.NODE_CLASS_MAPPINGS:
|
||||
if 'IPAdapterApply' in nodes.NODE_CLASS_MAPPINGS:
|
||||
raise Exception(f"[ERROR] 'ComfyUI IPAdapter Plus' is outdated.")
|
||||
|
||||
utils.try_install_custom_node('https://github.com/cubiq/ComfyUI_IPAdapter_plus',
|
||||
"To use 'IPAdapterApplySEGS' node, 'ComfyUI IPAdapter Plus' extension is required.")
|
||||
raise Exception(f"[ERROR] To use IPAdapterApplySEGS, you need to install 'ComfyUI IPAdapter Plus'")
|
||||
|
||||
obj = nodes.NODE_CLASS_MAPPINGS['IPAdapterApply']
|
||||
obj = nodes.NODE_CLASS_MAPPINGS['IPAdapterAdvanced']
|
||||
|
||||
ipadapter, _, clip_vision, insightface, lora_loader = self.ipadapter_pipe
|
||||
model = lora_loader(model)
|
||||
@@ -1537,10 +1541,10 @@ class IPAdapterWrapper:
|
||||
if self.prev_control_net is not None:
|
||||
model, prev_cnet_images = self.prev_control_net.doit_ipadapter(model)
|
||||
|
||||
model = obj().apply_ipadapter(ipadapter, model, self.weight, clip_vision=clip_vision, image=self.image,
|
||||
embeds=None, weight_type=self.weight_type, noise=self.noise,
|
||||
attn_mask=None, start_at=self.start_at, end_at=self.end_at,
|
||||
unfold_batch=self.unfold_batch, insightface=insightface, faceid_v2=self.faceid_v2, weight_v2=self.weight_v2)[0]
|
||||
model = obj().apply_ipadapter(model=model, ipadapter=ipadapter, weight=self.weight, weight_type=self.weight_type,
|
||||
start_at=self.start_at, end_at=self.end_at, combine_embeds=self.combine_embeds,
|
||||
clip_vision=clip_vision, image=self.image, attn_mask=None,
|
||||
insightface=insightface, weight_faceidv2=self.weight_v2)[0]
|
||||
|
||||
cnet_image_list.extend(prev_cnet_images)
|
||||
|
||||
|
||||
@@ -1182,7 +1182,10 @@ class IPAdapterApplySEGS:
|
||||
"weight_v2": ("FLOAT", {"default": 1.0, "min": -1, "max": 3, "step": 0.05}),
|
||||
"context_crop_factor": ("FLOAT", {"default": 1.2, "min": 1.0, "max": 100, "step": 0.1}),
|
||||
"reference_image": ("IMAGE",),
|
||||
}
|
||||
},
|
||||
"optional": {
|
||||
"combine_embeds": (["concat", "add", "subtract", "average", "norm average"],),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("SEGS",)
|
||||
@@ -1190,7 +1193,7 @@ class IPAdapterApplySEGS:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
def doit(self, segs, ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, context_crop_factor, reference_image):
|
||||
def doit(self, segs, ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, context_crop_factor, reference_image, combine_embeds="concat"):
|
||||
|
||||
if len(ipadapter_pipe) == 4:
|
||||
print(f"[Impact Pack] IPAdapterApplySEGS: Installed Inspire Pack is outdated.")
|
||||
@@ -1208,7 +1211,7 @@ class IPAdapterApplySEGS:
|
||||
context_crop_region = make_crop_region(w, h, seg.crop_region, context_crop_factor)
|
||||
cropped_image = crop_image(reference_image, context_crop_region)
|
||||
|
||||
control_net_wrapper = core.IPAdapterWrapper(ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, cropped_image, prev_control_net=seg.control_net_wrapper)
|
||||
control_net_wrapper = core.IPAdapterWrapper(ipadapter_pipe, weight, noise, weight_type, start_at, end_at, unfold_batch, faceid_v2, weight_v2, cropped_image, prev_control_net=seg.control_net_wrapper, combine_embeds=combine_embeds)
|
||||
new_seg = SEG(seg.cropped_image, seg.cropped_mask, seg.confidence, seg.crop_region, seg.bbox, seg.label, control_net_wrapper)
|
||||
new_segs.append(new_seg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user