什么是子图
这是一个将多个节点合并为一个节点的功能。 不仅可以整理外观,还可以将其作为可复用的模块(Blueprint: 蓝图)保存,并像新节点一样进行处理。
虽然可以将所有节点整合成一个,但 ComfyUI 的特征在于可以将图像生成管道划分为小的模块。
我个人认为,与其说它只是为了整顿外观,不如说是为了创建“可复用模块”而存在的功能。
创建子图
-
- 选中多个想要合并的节点
-
- 点击
Node Selection Toolbox的🕸️(Convert Selection to Subgraph)
- 点击
编辑子图
双击子图,或点击右上角的图标进入编辑模式。
基本操作与通常相同,但与外部交互的参数需要连接到子图的输入输出插槽(左侧/右侧)。
公开参数设置
可以将子图内的参数,作为子图节点的 Widget 公开表露出来。 这样无需每次都进入编辑模式即可更改数值。
-
- 选中子图
-
- 点击
Node Selection Toolbox的Edit Subgraph Widgets
- 点击
-
- 勾选想要公开的参数
子图的保存与复用
保存创建的子图后,可以将其作为独特的节点进行复用。
-
- 选中子图
-
- 点击
Node Selection Toolbox的📖(Publish Subgraph)
- 点击
-
- 输入名称并
Confirm
- 输入名称并
保存后,可以像普通节点一样通过搜索(双击)进行调用。
也可以从侧边栏的节点库中确认,并在此处进行 Blueprint 的删除或编辑。
{
"id": "a3364ead-7493-4912-8d6a-93d97d396e56",
"revision": 0,
"last_node_id": 23,
"last_link_id": 25,
"nodes": [
{
"id": 5,
"type": "JoinImageWithAlpha",
"pos": [
1674.6447738961886,
632.3248013583096
],
"size": [
176.86484375,
46
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2
},
{
"name": "alpha",
"type": "MASK",
"link": 25
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
20
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "JoinImageWithAlpha"
},
"widgets_values": []
},
{
"id": 1,
"type": "LoadImage",
"pos": [
982.0730322265621,
631.4157104492188
],
"size": [
347.95306396484375,
453.8662109375
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
2,
21
]
},
{
"name": "MASK",
"type": "MASK",
"links": null
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "LoadImage"
},
"widgets_values": [
"GB_test.png",
"image"
]
},
{
"id": 22,
"type": "bfc1244e-11c7-4ffd-a074-4342a2b8fddd",
"pos": [
1405.5464394992873,
755.382677721946
],
"size": [
212,
106
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 21
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
25
]
}
],
"properties": {
"proxyWidgets": [
[
"4",
"red"
],
[
"4",
"green"
],
[
"4",
"blue"
]
],
"cnr_id": "comfy-core",
"ver": "0.3.71"
},
"widgets_values": []
},
{
"id": 21,
"type": "PreviewImage",
"pos": [
1884.7735019531228,
631.4157104492188
],
"size": [
377.09303778542335,
438.18338923496117
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 20
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.71",
"Node name for S&R": "PreviewImage"
},
"widgets_values": []
}
],
"links": [
[
2,
1,
0,
5,
0,
"IMAGE"
],
[
20,
5,
0,
21,
0,
"IMAGE"
],
[
21,
1,
0,
22,
0,
"IMAGE"
],
[
25,
22,
0,
5,
1,
"MASK"
]
],
"groups": [],
"definitions": {
"subgraphs": [
{
"id": "bfc1244e-11c7-4ffd-a074-4342a2b8fddd",
"version": 1,
"state": {
"lastGroupId": 0,
"lastNodeId": 14,
"lastLinkId": 17,
"lastRerouteId": 0
},
"revision": 0,
"config": {},
"name": "Chroma Key",
"inputNode": {
"id": -10,
"bounding": [
1240.5157470703125,
757.3956909179688,
120,
60
]
},
"outputNode": {
"id": -20,
"bounding": [
2252.8402709960938,
757.3956909179688,
120,
60
]
},
"inputs": [
{
"id": "1d817b72-4293-49a6-a5b2-49f2109c07a7",
"name": "images",
"type": "IMAGE",
"linkIds": [
1
],
"localized_name": "images",
"pos": [
1340.5157470703125,
777.3956909179688
]
}
],
"outputs": [
{
"id": "25a7349f-9f55-4a69-9b31-f9916122c40a",
"name": "MASK",
"type": "MASK",
"linkIds": [
14
],
"localized_name": "MASK",
"pos": [
2272.8402709960938,
777.3956909179688
]
}
],
"widgets": [],
"nodes": [
{
"id": 11,
"type": "GrowMask",
"pos": [
1725.345458984375,
713.3956909179688
],
"size": [
220.4611358642578,
82
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"localized_name": "mask",
"name": "mask",
"type": "MASK",
"link": 11
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.51",
"Node name for S&R": "GrowMask"
},
"widgets_values": [
6,
true
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 13,
"type": "ImpactGaussianBlurMask",
"pos": [
1980.63623046875,
713.3956909179688
],
"size": [
212.20404052734375,
82
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"localized_name": "mask",
"name": "mask",
"type": "MASK",
"link": 13
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
14
]
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "f86c5afc68958afb89bf66898d6b5038ce98a096",
"Node name for S&R": "ImpactGaussianBlurMask"
},
"widgets_values": [
2,
5
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 4,
"type": "ColorToMask",
"pos": [
1420.5157470703125,
713.3956909179688
],
"size": [
270,
178
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"localized_name": "images",
"name": "images",
"type": "IMAGE",
"link": 1
}
],
"outputs": [
{
"localized_name": "MASK",
"name": "MASK",
"type": "MASK",
"links": [
11
]
}
],
"properties": {
"cnr_id": "comfyui-kjnodes",
"ver": "e2ce0843d1183aea86ce6a1617426f492dcdc802",
"Node name for S&R": "ColorToMask"
},
"widgets_values": [
false,
0,
255,
0,
10,
16
],
"color": "#232",
"bgcolor": "#353"
}
],
"groups": [],
"links": [
{
"id": 11,
"origin_id": 4,
"origin_slot": 0,
"target_id": 11,
"target_slot": 0,
"type": "MASK"
},
{
"id": 13,
"origin_id": 11,
"origin_slot": 0,
"target_id": 13,
"target_slot": 0,
"type": "MASK"
},
{
"id": 1,
"origin_id": -10,
"origin_slot": 0,
"target_id": 4,
"target_slot": 0,
"type": "IMAGE"
},
{
"id": 14,
"origin_id": 13,
"origin_slot": 0,
"target_id": -20,
"target_slot": 0,
"type": "MASK"
}
],
"extra": {}
}
]
},
"config": {},
"extra": {
"ds": {
"scale": 0.9782323058636119,
"offset": [
-182.127744825944,
-320.97800794421806
]
},
"frontendVersion": "1.30.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}