サブグラフとは
複数のノードを一つのノードに集約する機能です。 見た目を整えるだけでなく、再利用可能なモジュール(Blueprint)として保存し、新しいノードのように扱うことができます。
全てのノードを一つにまとめることも可能ですが、ComfyUIは画像生成のパイプラインを小さなモジュールに分けることができるのが特徴です。
単に見た目を整えるというよりは、あくまで「再利用可能なモジュール」を作成するための機能だと、個人的には考えています。
サブグラフの作成
-
- まとめたいノードを複数選択
-
Node Selection Toolboxの🕸️(Convert Selection to Subgraph) をクリック
サブグラフの編集
サブグラフをダブルクリック、または右上のアイコンをクリックして編集モードに入ります。
基本操作は通常と同じですが、外部とやり取りするパラメータは、サブグラフの入出力スロット(左端・右端)に接続する必要があります。
パラメータの公開設定
サブグラフ内のパラメータを、サブグラフノードのウィジェットとして表に出すことができます。 いちいち編集モードに入らずに値を変更できるようになります。
-
- サブグラフを選択
-
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
}