diff --git a/IPAdapterPlus.py b/IPAdapterPlus.py index 6f77550..93ec17f 100644 --- a/IPAdapterPlus.py +++ b/IPAdapterPlus.py @@ -172,8 +172,9 @@ def ipadapter_execute(model, is_sdxl = output_cross_attention_dim == 2048 if weight_type == "style transfer (SDXL)" and not is_sdxl: - weight_type = "linear" - print("\033[33mINFO: 'Style Transfer' weight type is only available for SDXL models, falling back to 'linear'.\033[0m") + raise Exception("Style Transfer weight type is only available for SDXL models") + #weight_type = "linear" + #print("\033[33mINFO: 'Style Transfer' weight type is only available for SDXL models, falling back to 'linear'.\033[0m") if is_faceid and not insightface: raise Exception("insightface model is required for FaceID models") @@ -493,6 +494,7 @@ class IPAdapterSimple: "weight": ("FLOAT", { "default": 1.0, "min": -1, "max": 3, "step": 0.05 }), "start_at": ("FLOAT", { "default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001 }), "end_at": ("FLOAT", { "default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001 }), + "weight_type": (['standard', 'prompt is more important', 'style transfer (SDXL only)'], ), }, "optional": { "attn_mask": ("MASK",), @@ -503,13 +505,21 @@ class IPAdapterSimple: FUNCTION = "apply_ipadapter" CATEGORY = "ipadapter" - def apply_ipadapter(self, model, ipadapter, image, weight, start_at, end_at, attn_mask=None): + def apply_ipadapter(self, model, ipadapter, image, weight, start_at, end_at, weight_type, attn_mask=None): + if weight_type == "style transfer (SDXL only)": + weight_type = "style transfer (SDXL)" + elif weight_type == "prompt is more important": + weight_type = "ease out" + else: + weight_type = "linear" + ipa_args = { "image": image, "weight": weight, "start_at": start_at, "end_at": end_at, "attn_mask": attn_mask, + "weight_type": weight_type, "insightface": ipadapter['insightface']['model'] if 'insightface' in ipadapter else None, } diff --git a/examples/ipadapter_advanced.json b/examples/ipadapter_advanced.json index ae712dd..b085824 100644 --- a/examples/ipadapter_advanced.json +++ b/examples/ipadapter_advanced.json @@ -57,10 +57,10 @@ 1770, 710 ], - "size": [ - 529.7760009765616, - 582.3048192804504 - ], + "size": { + "0": 529.7760009765625, + "1": 582.3048095703125 + }, "flags": {}, "order": 11, "mode": 0, @@ -121,10 +121,10 @@ 1570, 700 ], - "size": [ - 140, - 46 - ], + "size": { + "0": 140, + "1": 46 + }, "flags": {}, "order": 10, "mode": 0, @@ -187,218 +187,6 @@ 1 ] }, - { - "id": 16, - "type": "CLIPVisionLoader", - "pos": [ - 308, - 161 - ], - "size": { - "0": 315, - "1": 58 - }, - "flags": {}, - "order": 2, - "mode": 0, - "outputs": [ - { - "name": "CLIP_VISION", - "type": "CLIP_VISION", - "links": [ - 24 - ], - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "CLIPVisionLoader" - }, - "widgets_values": [ - "IPAdapter_image_encoder_sd15.safetensors" - ] - }, - { - "id": 15, - "type": "IPAdapterModelLoader", - "pos": [ - 308, - 52 - ], - "size": { - "0": 315, - "1": 58 - }, - "flags": {}, - "order": 3, - "mode": 0, - "outputs": [ - { - "name": "IPADAPTER", - "type": "IPADAPTER", - "links": [ - 21 - ], - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "IPAdapterModelLoader" - }, - "widgets_values": [ - "ip-adapter-plus_sd15.safetensors" - ] - }, - { - "id": 14, - "type": "IPAdapterAdvanced", - "pos": [ - 793, - 304 - ], - "size": { - "0": 315, - "1": 254 - }, - "flags": {}, - "order": 8, - "mode": 0, - "inputs": [ - { - "name": "model", - "type": "MODEL", - "link": 20 - }, - { - "name": "ipadapter", - "type": "IPADAPTER", - "link": 21, - "slot_index": 1 - }, - { - "name": "image", - "type": "IMAGE", - "link": 26 - }, - { - "name": "image_negative", - "type": "IMAGE", - "link": null - }, - { - "name": "attn_mask", - "type": "MASK", - "link": null - }, - { - "name": "clip_vision", - "type": "CLIP_VISION", - "link": 24, - "slot_index": 5 - } - ], - "outputs": [ - { - "name": "MODEL", - "type": "MODEL", - "links": [ - 23 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "IPAdapterAdvanced" - }, - "widgets_values": [ - 0.8, - "linear", - "concat", - 0, - 1 - ] - }, - { - "id": 17, - "type": "PrepImageForClipVision", - "pos": [ - 798, - 145 - ], - "size": { - "0": 315, - "1": 106 - }, - "flags": {}, - "order": 7, - "mode": 0, - "inputs": [ - { - "name": "image", - "type": "IMAGE", - "link": 25 - } - ], - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 26 - ], - "shape": 3, - "slot_index": 0 - } - ], - "properties": { - "Node name for S&R": "PrepImageForClipVision" - }, - "widgets_values": [ - "LANCZOS", - "top", - 0.15 - ] - }, - { - "id": 12, - "type": "LoadImage", - "pos": [ - 311, - 270 - ], - "size": [ - 315, - 314 - ], - "flags": {}, - "order": 4, - "mode": 0, - "outputs": [ - { - "name": "IMAGE", - "type": "IMAGE", - "links": [ - 25 - ], - "shape": 3, - "slot_index": 0 - }, - { - "name": "MASK", - "type": "MASK", - "links": null, - "shape": 3 - } - ], - "properties": { - "Node name for S&R": "LoadImage" - }, - "widgets_values": [ - "girl_sitting.png", - "image" - ] - }, { "id": 6, "type": "CLIPTextEncode", @@ -495,6 +283,219 @@ "karras", 1 ] + }, + { + "id": 14, + "type": "IPAdapterAdvanced", + "pos": [ + 801, + 256 + ], + "size": { + "0": 315, + "1": 278 + }, + "flags": {}, + "order": 8, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 20 + }, + { + "name": "ipadapter", + "type": "IPADAPTER", + "link": 21, + "slot_index": 1 + }, + { + "name": "image", + "type": "IMAGE", + "link": 26 + }, + { + "name": "image_negative", + "type": "IMAGE", + "link": null + }, + { + "name": "attn_mask", + "type": "MASK", + "link": null + }, + { + "name": "clip_vision", + "type": "CLIP_VISION", + "link": 24, + "slot_index": 5 + } + ], + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 23 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "IPAdapterAdvanced" + }, + "widgets_values": [ + 0.8, + "linear", + "concat", + 0, + 1, + "V only" + ] + }, + { + "id": 17, + "type": "PrepImageForClipVision", + "pos": [ + 797, + 87 + ], + "size": { + "0": 315, + "1": 106 + }, + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 25 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 26 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "PrepImageForClipVision" + }, + "widgets_values": [ + "LANCZOS", + "top", + 0.15 + ] + }, + { + "id": 15, + "type": "IPAdapterModelLoader", + "pos": [ + 308, + 52 + ], + "size": { + "0": 315, + "1": 58 + }, + "flags": {}, + "order": 2, + "mode": 0, + "outputs": [ + { + "name": "IPADAPTER", + "type": "IPADAPTER", + "links": [ + 21 + ], + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "IPAdapterModelLoader" + }, + "widgets_values": [ + "ip-adapter-plus_sd15.safetensors" + ] + }, + { + "id": 16, + "type": "CLIPVisionLoader", + "pos": [ + 308, + 161 + ], + "size": { + "0": 315, + "1": 58 + }, + "flags": {}, + "order": 3, + "mode": 0, + "outputs": [ + { + "name": "CLIP_VISION", + "type": "CLIP_VISION", + "links": [ + 24 + ], + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "CLIPVisionLoader" + }, + "widgets_values": [ + "CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors" + ] + }, + { + "id": 12, + "type": "LoadImage", + "pos": [ + 311, + 270 + ], + "size": { + "0": 315, + "1": 314 + }, + "flags": {}, + "order": 4, + "mode": 0, + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 25 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "MASK", + "type": "MASK", + "links": null, + "shape": 3 + } + ], + "properties": { + "Node name for S&R": "LoadImage" + }, + "widgets_values": [ + "warrior_woman.png", + "image" + ] } ], "links": [