add support to clip skip to comfyui backend

pull/369/head
Abdullah Alfaraj 2023-11-23 08:48:36 +03:00
parent 78a6aabe8d
commit f81b8a6679
6 changed files with 910 additions and 750 deletions

View File

@ -199,8 +199,8 @@
0
],
"clip": [
"16",
1
"109",
0
]
},
"class_type": "LoadLorasFromPrompt"
@ -213,19 +213,12 @@
0
],
"clip": [
"16",
1
"109",
0
]
},
"class_type": "LoadLorasFromPrompt"
},
"87": {
"inputs": {
"image": "ComfyUI_temp_cqoqp_00001_.png",
"choose file to upload": "image"
},
"class_type": "LoadImage"
},
"88": {
"inputs": {
"images": [
@ -255,17 +248,21 @@
},
"91": {
"inputs": {
"is_enabled_1": "enable",
"is_enabled_1": "disable",
"preprocessor_name_1": "CannyEdgePreprocessor",
"control_net_name_1": "control_lora_rank128_v11p_sd15_canny_fp16.safetensors",
"strength_1": 1,
"threshold_a_1": 100,
"threshold_b_1": 200,
"start_percent_1": 0,
"end_percent_1": 1,
"resolution_1": 512,
"is_enabled_2": "disable",
"preprocessor_name_2": "CannyEdgePreprocessor",
"control_net_name_2": "control_lora_rank128_v11e_sd15_ip2p_fp16.safetensors",
"preprocessor_name_2": "OpenposePreprocessor",
"control_net_name_2": "control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
"strength_2": 1,
"threshold_a_2": 0,
"threshold_b_2": 0,
"start_percent_2": 0,
"end_percent_2": 1,
"resolution_2": 512,
@ -273,6 +270,8 @@
"preprocessor_name_3": "InpaintPreprocessor",
"control_net_name_3": "control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
"strength_3": 1,
"threshold_a_3": 0,
"threshold_b_3": 0,
"start_percent_3": 0,
"end_percent_3": 1,
"resolution_3": 512,
@ -283,12 +282,18 @@
"negative": [
"7",
0
],
"image_1": [
"87",
0
]
},
"class_type": "ControlNetScript"
},
"109": {
"inputs": {
"stop_at_clip_layer": -1,
"clip": [
"16",
1
]
},
"class_type": "CLIPSetLastLayer"
}
}

View File

@ -166,8 +166,8 @@
0
],
"clip": [
"16",
1
"162",
0
]
},
"class_type": "LoadLorasFromPrompt"
@ -180,8 +180,8 @@
0
],
"clip": [
"16",
1
"162",
0
]
},
"class_type": "LoadLorasFromPrompt"
@ -282,13 +282,17 @@
"preprocessor_name_1": "OpenposePreprocessor",
"control_net_name_1": "control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
"strength_1": 1,
"threshold_a_1": 100,
"threshold_b_1": 200,
"start_percent_1": 0,
"end_percent_1": 1,
"resolution_1": 512,
"is_enabled_2": "disable",
"preprocessor_name_2": "InpaintPreprocessor",
"control_net_name_2": "control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
"preprocessor_name_2": "OpenposePreprocessor",
"control_net_name_2": "control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
"strength_2": 1,
"threshold_a_2": 0,
"threshold_b_2": 0,
"start_percent_2": 0,
"end_percent_2": 1,
"resolution_2": 512,
@ -296,6 +300,8 @@
"preprocessor_name_3": "InpaintPreprocessor",
"control_net_name_3": "control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
"strength_3": 1,
"threshold_a_3": 0,
"threshold_b_3": 0,
"start_percent_3": 0,
"end_percent_3": 1,
"resolution_3": 512,
@ -322,6 +328,14 @@
"mask_2": [
"83",
0
],
"image_3": [
"58",
0
],
"mask_3": [
"83",
0
]
},
"class_type": "ControlNetScript"
@ -335,5 +349,15 @@
]
},
"class_type": "RepeatLatentBatch"
},
"162": {
"inputs": {
"stop_at_clip_layer": -1,
"clip": [
"16",
1
]
},
"class_type": "CLIPSetLastLayer"
}
}

View File

@ -1,6 +1,6 @@
{
"last_node_id": 160,
"last_link_id": 306,
"last_node_id": 162,
"last_link_id": 311,
"nodes": [
{
"id": 13,
@ -14,7 +14,7 @@
"1": 46
},
"flags": {},
"order": 36,
"order": 37,
"mode": 0,
"inputs": [
{
@ -54,7 +54,7 @@
26
],
"flags": {},
"order": 20,
"order": 25,
"mode": 0,
"inputs": [
{
@ -126,7 +126,7 @@
26
],
"flags": {},
"order": 17,
"order": 16,
"mode": 0,
"inputs": [
{
@ -200,7 +200,7 @@
"1": 46
},
"flags": {},
"order": 33,
"order": 34,
"mode": 0,
"inputs": [
{
@ -277,7 +277,7 @@
"1": 82
},
"flags": {},
"order": 32,
"order": 33,
"mode": 0,
"inputs": [
{
@ -318,7 +318,7 @@
"1": 474
},
"flags": {},
"order": 34,
"order": 35,
"mode": 0,
"inputs": [
{
@ -382,7 +382,7 @@
26
],
"flags": {},
"order": 19,
"order": 24,
"mode": 0,
"inputs": [
{
@ -419,7 +419,7 @@
"1": 200
},
"flags": {},
"order": 9,
"order": 15,
"mode": 0,
"inputs": [
{
@ -430,7 +430,7 @@
{
"name": "clip",
"type": "CLIP",
"link": 139
"link": 309
}
],
"outputs": [
@ -515,7 +515,7 @@
"1": 246
},
"flags": {},
"order": 23,
"order": 22,
"mode": 2,
"inputs": [
{
@ -540,7 +540,7 @@
"1": 246
},
"flags": {},
"order": 24,
"order": 23,
"mode": 2,
"inputs": [
{
@ -565,7 +565,7 @@
"1": 246
},
"flags": {},
"order": 22,
"order": 21,
"mode": 2,
"inputs": [
{
@ -622,7 +622,7 @@
"1": 200
},
"flags": {},
"order": 14,
"order": 18,
"mode": 0,
"inputs": [
{
@ -633,7 +633,7 @@
{
"name": "clip",
"type": "CLIP",
"link": 132
"link": 310
}
],
"outputs": [
@ -685,7 +685,7 @@
"1": 164.31304931640625
},
"flags": {},
"order": 25,
"order": 27,
"mode": 0,
"inputs": [
{
@ -733,7 +733,7 @@
"1": 180.6060791015625
},
"flags": {},
"order": 15,
"order": 19,
"mode": 0,
"inputs": [
{
@ -781,7 +781,7 @@
"1": 282.4336242675781
},
"flags": {},
"order": 35,
"order": 36,
"mode": 0,
"inputs": [
{
@ -862,273 +862,6 @@
768
]
},
{
"id": 16,
"type": "CheckpointLoaderSimple",
"pos": [
-3105,
1139
],
"size": {
"0": 315,
"1": 98
},
"flags": {},
"order": 4,
"mode": 0,
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
141
],
"slot_index": 0
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
132,
139
],
"slot_index": 1
},
{
"name": "VAE",
"type": "VAE",
"links": [],
"slot_index": 2
}
],
"title": "Load Checkpoint | id:checkpoint",
"properties": {
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"aniverse_v15Pruned.safetensors"
]
},
{
"id": 159,
"type": "ControlNetScript",
"pos": [
-1160,
70
],
"size": {
"0": 506.0240173339844,
"1": 678
},
"flags": {},
"order": 27,
"mode": 0,
"inputs": [
{
"name": "positive",
"type": "CONDITIONING",
"link": 294
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 295,
"slot_index": 1
},
{
"name": "image_1",
"type": "IMAGE",
"link": 296
},
{
"name": "mask_1",
"type": "IMAGE",
"link": 304,
"slot_index": 3
},
{
"name": "image_2",
"type": "IMAGE",
"link": 303
},
{
"name": "mask_2",
"type": "IMAGE",
"link": 302
},
{
"name": "image_3",
"type": "IMAGE",
"link": null
},
{
"name": "mask_3",
"type": "IMAGE",
"link": null
}
],
"outputs": [
{
"name": "preprocessed_image_1",
"type": "IMAGE",
"links": [
291
],
"shape": 3,
"slot_index": 0
},
{
"name": "preprocessed_image_2",
"type": "IMAGE",
"links": [
292
],
"shape": 3,
"slot_index": 1
},
{
"name": "preprocessed_image_3",
"type": "IMAGE",
"links": [
293
],
"shape": 3,
"slot_index": 2
},
{
"name": "positive",
"type": "CONDITIONING",
"links": [
298
],
"shape": 3,
"slot_index": 3
},
{
"name": "negative",
"type": "CONDITIONING",
"links": [
299
],
"shape": 3,
"slot_index": 4
}
],
"title": "ControlNet Script | id:controlnet_script",
"properties": {
"Node name for S&R": "ControlNetScript"
},
"widgets_values": [
"disable",
"OpenposePreprocessor",
"control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
1,
0,
1,
512,
"disable",
"InpaintPreprocessor",
"control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
1,
0,
1,
512,
"disable",
"InpaintPreprocessor",
"control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
1,
0,
1,
512
]
},
{
"id": 147,
"type": "ImageScale",
"pos": [
-1070,
-680
],
"size": {
"0": 315,
"1": 130
},
"flags": {},
"order": 10,
"mode": 4,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 274
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
296,
303
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
512,
768,
"disabled"
]
},
{
"id": 152,
"type": "ImageScale",
"pos": [
-1030,
-1050
],
"size": {
"0": 315,
"1": 130
},
"flags": {},
"order": 11,
"mode": 4,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 282
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
283,
302,
304
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
512,
768,
"disabled"
]
},
{
"id": 153,
"type": "ImageToMask",
@ -1141,7 +874,7 @@
"1": 58
},
"flags": {},
"order": 16,
"order": 14,
"mode": 4,
"inputs": [
{
@ -1178,7 +911,7 @@
"1": 314
},
"flags": {},
"order": 5,
"order": 4,
"mode": 0,
"outputs": [
{
@ -1219,7 +952,7 @@
"1": 314
},
"flags": {},
"order": 6,
"order": 5,
"mode": 0,
"outputs": [
{
@ -1261,7 +994,7 @@
"1": 446
},
"flags": {},
"order": 31,
"order": 32,
"mode": 0,
"inputs": [
{
@ -1310,7 +1043,7 @@
"Node name for S&R": "KSampler"
},
"widgets_values": [
109789101278740,
794911936203426,
"randomize",
20,
7,
@ -1331,7 +1064,7 @@
"1": 468.13226318359375
},
"flags": {},
"order": 37,
"order": 38,
"mode": 0,
"inputs": [
{
@ -1358,7 +1091,7 @@
"1": 82
},
"flags": {},
"order": 7,
"order": 6,
"mode": 0,
"outputs": [
{
@ -1393,7 +1126,7 @@
26
],
"flags": {},
"order": 21,
"order": 20,
"mode": 0,
"inputs": [
{
@ -1431,7 +1164,7 @@
"1": 214
},
"flags": {},
"order": 18,
"order": 17,
"mode": 0,
"inputs": [
{
@ -1522,7 +1255,7 @@
"original",
512,
768,
933689295201272,
455409161612873,
"randomize"
]
},
@ -1578,7 +1311,7 @@
"1": 246
},
"flags": {},
"order": 29,
"order": 30,
"mode": 0,
"inputs": [
{
@ -1592,32 +1325,6 @@
"Node name for S&R": "PreviewImage"
}
},
{
"id": 158,
"type": "PreviewImage",
"pos": [
-370,
-240
],
"size": {
"0": 336,
"1": 246
},
"flags": {},
"order": 30,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 293
}
],
"title": "Preview Image | id:preprocessor_output_3",
"properties": {
"Node name for S&R": "PreviewImage"
}
},
{
"id": 156,
"type": "PreviewImage",
@ -1630,7 +1337,7 @@
"1": 246
},
"flags": {},
"order": 28,
"order": 29,
"mode": 0,
"inputs": [
{
@ -1643,6 +1350,347 @@
"properties": {
"Node name for S&R": "PreviewImage"
}
},
{
"id": 159,
"type": "ControlNetScript",
"pos": [
-1160,
70
],
"size": {
"0": 506.0240173339844,
"1": 822
},
"flags": {},
"order": 28,
"mode": 0,
"inputs": [
{
"name": "positive",
"type": "CONDITIONING",
"link": 294
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 295,
"slot_index": 1
},
{
"name": "image_1",
"type": "IMAGE",
"link": 296
},
{
"name": "mask_1",
"type": "IMAGE",
"link": 304,
"slot_index": 3
},
{
"name": "image_2",
"type": "IMAGE",
"link": 303
},
{
"name": "mask_2",
"type": "IMAGE",
"link": 302
},
{
"name": "image_3",
"type": "IMAGE",
"link": 307
},
{
"name": "mask_3",
"type": "IMAGE",
"link": 308
}
],
"outputs": [
{
"name": "preprocessed_image_1",
"type": "IMAGE",
"links": [
291
],
"shape": 3,
"slot_index": 0
},
{
"name": "preprocessed_image_2",
"type": "IMAGE",
"links": [
292
],
"shape": 3,
"slot_index": 1
},
{
"name": "preprocessed_image_3",
"type": "IMAGE",
"links": [
293
],
"shape": 3,
"slot_index": 2
},
{
"name": "positive",
"type": "CONDITIONING",
"links": [
298
],
"shape": 3,
"slot_index": 3
},
{
"name": "negative",
"type": "CONDITIONING",
"links": [
299
],
"shape": 3,
"slot_index": 4
}
],
"title": "ControlNet Script | id:controlnet_script",
"properties": {
"Node name for S&R": "ControlNetScript"
},
"widgets_values": [
"disable",
"OpenposePreprocessor",
"control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
1,
100,
200,
0,
1,
512,
"disable",
"OpenposePreprocessor",
"control_lora_rank128_v11p_sd15_openpose_fp16.safetensors",
1,
0,
0,
0,
1,
512,
"disable",
"InpaintPreprocessor",
"control_lora_rank128_v11p_sd15_inpaint_fp16.safetensors",
1,
0,
0,
0,
1,
512
]
},
{
"id": 158,
"type": "PreviewImage",
"pos": [
-330,
-212
],
"size": {
"0": 336,
"1": 246
},
"flags": {},
"order": 31,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 293
}
],
"title": "Preview Image | id:preprocessor_output_3",
"properties": {
"Node name for S&R": "PreviewImage"
}
},
{
"id": 147,
"type": "ImageScale",
"pos": [
-1084,
-646
],
"size": {
"0": 315,
"1": 130
},
"flags": {},
"order": 9,
"mode": 4,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 274
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
296,
303,
307
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
512,
768,
"disabled"
]
},
{
"id": 152,
"type": "ImageScale",
"pos": [
-1030,
-1050
],
"size": {
"0": 315,
"1": 130
},
"flags": {},
"order": 10,
"mode": 4,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 282
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
283,
302,
304,
308
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "ImageScale"
},
"widgets_values": [
"nearest-exact",
512,
768,
"disabled"
]
},
{
"id": 16,
"type": "CheckpointLoaderSimple",
"pos": [
-3298,
1138
],
"size": {
"0": 315,
"1": 98
},
"flags": {},
"order": 7,
"mode": 0,
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
141
],
"slot_index": 0
},
{
"name": "CLIP",
"type": "CLIP",
"links": [
311
],
"slot_index": 1
},
{
"name": "VAE",
"type": "VAE",
"links": [],
"slot_index": 2
}
],
"title": "Load Checkpoint | id:checkpoint",
"properties": {
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"aniverse_v15Pruned.safetensors"
]
},
{
"id": 162,
"type": "CLIPSetLastLayer",
"pos": [
-2959,
1098
],
"size": {
"0": 315,
"1": 58
},
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 311
}
],
"outputs": [
{
"name": "CLIP",
"type": "CLIP",
"links": [
309,
310
],
"shape": 3,
"slot_index": 0
}
],
"title": "CLIP Set Last Layer | id:clip_skip",
"properties": {
"Node name for S&R": "CLIPSetLastLayer"
},
"widgets_values": [
-1
]
}
],
"links": [
@ -1718,14 +1766,6 @@
0,
"CLIP"
],
[
132,
16,
1,
76,
1,
"CLIP"
],
[
133,
76,
@ -1766,14 +1806,6 @@
0,
"CLIP"
],
[
139,
16,
1,
78,
1,
"CLIP"
],
[
140,
78,
@ -2069,6 +2101,46 @@
3,
3,
"LATENT"
],
[
307,
147,
0,
159,
6,
"IMAGE"
],
[
308,
152,
0,
159,
7,
"IMAGE"
],
[
309,
162,
0,
78,
1,
"CLIP"
],
[
310,
162,
0,
76,
1,
"CLIP"
],
[
311,
16,
1,
162,
0,
"CLIP"
]
],
"groups": [

View File

@ -1,8 +1,8 @@
import txt2img from './txt2img_workflow.json'
import txt2img_api from './txt2img_api.json'
import img2img from './img2img_workflow_v0.0.6.json'
import img2img_api from './img2img_api_v0.0.6.json'
import img2img from './img2img_workflow.json'
import img2img_api from './img2img_api.json'
import inpaint from './inpaint_workflow.json'
import inpaint_api from './inpaint_api.json'
@ -119,6 +119,7 @@ function mutePromptNode(nodes: any[], prompt: any, node_name_id: string) {
}
const txt2img_map: Record<string, any> = {
model: 'checkpoint.ckpt_name',
comfy_clip_skip: 'clip_skip.stop_at_clip_layer',
vae: 'vae.vae_name',
width: 'latent_image.width',
height: 'latent_image.height',
@ -162,6 +163,7 @@ const controlnet_txt2img_map: Record<string, any> = {
const img2img_map: Record<string, any> = {
init_image: 'init_image.image', // note: this is not init_images but init_image
model: 'checkpoint.ckpt_name',
comfy_clip_skip: 'clip_skip.stop_at_clip_layer',
vae: 'vae.vae_name',
width: 'init_image_scale.width',
height: 'init_image_scale.height',
@ -193,8 +195,8 @@ const img2img_map: Record<string, any> = {
const inpaint_map: Record<string, any> = {
init_image: 'init_image.image', // note: this is not init_images but init_image
comfy_mask: 'mask_image.image',
model: 'checkpoint.ckpt_name',
comfy_clip_skip: 'clip_skip.stop_at_clip_layer',
vae: 'vae.vae_name',
width: 'width.Value',
height: 'height.Value',
@ -252,6 +254,7 @@ async function addMissingSettings(plugin_settings: Record<string, any>) {
plugin_settings['hr_denoising_strength'] =
sd_tab_util.store.data.hr_denoising_strength
plugin_settings['hr_sampler_name'] = sd_tab_util.store.data.sampler_name // use the same sampler for the first and second pass (hires) upscale sampling steps
plugin_settings['comfy_clip_skip'] = -1 * plugin_settings['clip_skip']
if ('init_images' in plugin_settings) {
const base64 = plugin_settings['init_images'][0]

View File

@ -416,6 +416,8 @@ async function getSettings(session_data) {
payload['original_negative_prompt'] = negative_prompt
}
payload['clip_skip'] =
settings_tab_ts.store.data.CLIP_stop_at_last_layers
payload = {
...payload,
// prompt: prompt,