What is Differential Diffusion?
In normal inpainting, the white areas of the mask change while the black areas do not.
So does making an area gray change it just a little? Unfortunately, it does not give you that kind of control on its own.
That is where Differential Diffusion comes in.
It lets you change denoise at each location according to the intensity of the mask, so different areas can change by different amounts and blurred mask boundaries can work as expected.
If you have not read inpainting yet, please start there.
Usage
Add the Differential Diffusion node to an inpainting workflow, then give the mask different shades.
workflow

{
"id": "8b9f7796-0873-4025-be3c-0f997f67f866",
"revision": 0,
"last_node_id": 19,
"last_link_id": 23,
"nodes": [
{
"id": 12,
"type": "VAEEncode",
"pos": [
436.45541132111384,
672.3101875706969
],
"size": [
140,
46
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "pixels",
"type": "IMAGE",
"link": 11
},
{
"name": "vae",
"type": "VAE",
"link": 13
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
14
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAEEncode"
},
"widgets_values": []
},
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
416.1970166015625,
392.37848510742185
],
"size": [
410.75801513671877,
158.82607910156253
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 5
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
6
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"text, watermark, worst quality"
]
},
{
"id": 9,
"type": "SaveImage",
"pos": [
1451,
189
],
"size": [
503.2876035004722,
576.239673217884
],
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 8,
"type": "VAEDecode",
"pos": [
1209,
188
],
"size": [
203.39999999999986,
46
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 7
},
{
"name": "vae",
"type": "VAE",
"link": 10
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 11,
"type": "LoadImage",
"pos": [
-46.552421344122806,
724.4939982393679
],
"size": [
348.6485235795455,
444.65055454545484
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
11
]
},
{
"name": "MASK",
"type": "MASK",
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImage",
"image": "clipspace/clipspace-painted-masked-1765071052914.png [input]"
},
"widgets_values": [
"8d2eb48340cf6f6f99e539e11517d6a2.png",
"image"
]
},
{
"id": 13,
"type": "SetLatentNoiseMask",
"pos": [
609.0212780548253,
672.3101875706969
],
"size": [
208.02038352272726,
46
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 14
},
{
"name": "mask",
"type": "MASK",
"link": 23
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
16
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "SetLatentNoiseMask"
},
"widgets_values": []
},
{
"id": 10,
"type": "VAELoader",
"pos": [
167.95849892963756,
598.568575275356
],
"size": [
231.48760330578511,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
10,
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"vae-ft-mse-840000-ema-pruned.safetensors"
]
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
415,
186
],
"size": [
411.95503173828126,
151.0030493164063
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 3
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
4
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"RAW Photograph of a cross section of a kiwi for commercial use."
]
},
{
"id": 19,
"type": "LoadImageMask",
"pos": [
322.4453331961138,
798.0790526061061
],
"size": [
254.01007812500006,
368.578
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
23
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImageMask"
},
"widgets_values": [
"d8cd78b75de91ed4e9a1da1eedfcf21d.png",
"red",
"image"
]
},
{
"id": 4,
"type": "CheckpointLoaderSimple",
"pos": [
39.900463636363625,
343.9095500000008
],
"size": [
315,
98
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"slot_index": 0,
"links": [
21
]
},
{
"name": "CLIP",
"type": "CLIP",
"slot_index": 1,
"links": [
3,
5
]
},
{
"name": "VAE",
"type": "VAE",
"slot_index": 2,
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"v1-5-pruned-emaonly-fp16.safetensors"
]
},
{
"id": 3,
"type": "KSampler",
"pos": [
863,
186
],
"size": [
315,
262
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 22
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 4
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 6
},
{
"name": "latent_image",
"type": "LATENT",
"link": 16
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"slot_index": 0,
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "KSampler"
},
"widgets_values": [
111111,
"fixed",
20,
8,
"euler",
"normal",
1
]
},
{
"id": 18,
"type": "DifferentialDiffusion",
"pos": [
526.0722281128822,
67.3403636363635
],
"size": [
210,
58
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 21
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
22
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "DifferentialDiffusion"
},
"widgets_values": [
1
],
"color": "#232",
"bgcolor": "#353"
}
],
"links": [
[
3,
4,
1,
6,
0,
"CLIP"
],
[
4,
6,
0,
3,
1,
"CONDITIONING"
],
[
5,
4,
1,
7,
0,
"CLIP"
],
[
6,
7,
0,
3,
2,
"CONDITIONING"
],
[
7,
3,
0,
8,
0,
"LATENT"
],
[
9,
8,
0,
9,
0,
"IMAGE"
],
[
10,
10,
0,
8,
1,
"VAE"
],
[
11,
11,
0,
12,
0,
"IMAGE"
],
[
13,
10,
0,
12,
1,
"VAE"
],
[
14,
12,
0,
13,
0,
"LATENT"
],
[
16,
13,
0,
3,
3,
"LATENT"
],
[
21,
4,
0,
18,
0,
"MODEL"
],
[
22,
18,
0,
3,
0,
"MODEL"
],
[
23,
19,
0,
13,
1,
"MASK"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.620921323059155,
"offset": [
146.55242134412282,
24.607086363636487
]
},
"frontendVersion": "1.34.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 🟩 Add the
Differential Diffusionnode - This example is based on a workflow using the
Set Latent Noise Masknode.- It also works with workflows using inpainting models or ControlNet models.
Whiter areas change more, while darker areas retain more of the original image.
Using the Mask
Change Different Areas by Different Amounts
The mask does not need to use a smooth gradient.
By using different shades for different areas in a single mask image, you can give each area a different amount of change in one sampling pass.

{
"id": "8b9f7796-0873-4025-be3c-0f997f67f866",
"revision": 0,
"last_node_id": 19,
"last_link_id": 23,
"nodes": [
{
"id": 12,
"type": "VAEEncode",
"pos": [
436.45541132111384,
672.3101875706969
],
"size": [
140,
46
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "pixels",
"type": "IMAGE",
"link": 11
},
{
"name": "vae",
"type": "VAE",
"link": 13
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
14
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAEEncode"
},
"widgets_values": []
},
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
416.1970166015625,
392.37848510742185
],
"size": [
410.75801513671877,
158.82607910156253
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 5
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
6
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"text, watermark, worst quality"
]
},
{
"id": 9,
"type": "SaveImage",
"pos": [
1451,
189
],
"size": [
503.2876035004722,
576.239673217884
],
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 8,
"type": "VAEDecode",
"pos": [
1209,
188
],
"size": [
203.39999999999986,
46
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 7
},
{
"name": "vae",
"type": "VAE",
"link": 10
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 11,
"type": "LoadImage",
"pos": [
-46.552421344122806,
724.4939982393679
],
"size": [
348.6485235795455,
444.65055454545484
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
11
]
},
{
"name": "MASK",
"type": "MASK",
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImage",
"image": "clipspace/clipspace-painted-masked-1765071052914.png [input]"
},
"widgets_values": [
"ff958820180efd9b316cb42ddd9c0276.png",
"image"
]
},
{
"id": 13,
"type": "SetLatentNoiseMask",
"pos": [
609.0212780548253,
672.3101875706969
],
"size": [
208.02038352272726,
46
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 14
},
{
"name": "mask",
"type": "MASK",
"link": 23
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
16
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "SetLatentNoiseMask"
},
"widgets_values": []
},
{
"id": 10,
"type": "VAELoader",
"pos": [
167.95849892963756,
598.568575275356
],
"size": [
231.48760330578511,
58
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
10,
13
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"vae-ft-mse-840000-ema-pruned.safetensors"
]
},
{
"id": 19,
"type": "LoadImageMask",
"pos": [
322.4453331961138,
798.0790526061061
],
"size": [
254.01007812500006,
368.578
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
23
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImageMask"
},
"widgets_values": [
"2d0d14ad85109598f389e5ac0ad7b85f.png",
"red",
"image"
]
},
{
"id": 4,
"type": "CheckpointLoaderSimple",
"pos": [
39.900463636363625,
343.9095500000008
],
"size": [
315,
98
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"slot_index": 0,
"links": [
21
]
},
{
"name": "CLIP",
"type": "CLIP",
"slot_index": 1,
"links": [
3,
5
]
},
{
"name": "VAE",
"type": "VAE",
"slot_index": 2,
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"v1-5-pruned-emaonly-fp16.safetensors"
]
},
{
"id": 18,
"type": "DifferentialDiffusion",
"pos": [
526.0722281128822,
67.3403636363635
],
"size": [
210,
58
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 21
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
22
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "DifferentialDiffusion"
},
"widgets_values": [
1
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
415,
186
],
"size": [
411.95503173828126,
151.0030493164063
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 3
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
4
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"high quality,high detailed,RAW Photograph of a cross section of a kiwi for commercial use.RAW Photograph of a cross section of a kiwi for commercial use."
]
},
{
"id": 3,
"type": "KSampler",
"pos": [
863,
186
],
"size": [
315,
262
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 22
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 4
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 6
},
{
"name": "latent_image",
"type": "LATENT",
"link": 16
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"slot_index": 0,
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "KSampler"
},
"widgets_values": [
3,
"fixed",
20,
8,
"euler",
"normal",
0.93
]
}
],
"links": [
[
3,
4,
1,
6,
0,
"CLIP"
],
[
4,
6,
0,
3,
1,
"CONDITIONING"
],
[
5,
4,
1,
7,
0,
"CLIP"
],
[
6,
7,
0,
3,
2,
"CONDITIONING"
],
[
7,
3,
0,
8,
0,
"LATENT"
],
[
9,
8,
0,
9,
0,
"IMAGE"
],
[
10,
10,
0,
8,
1,
"VAE"
],
[
11,
11,
0,
12,
0,
"IMAGE"
],
[
13,
10,
0,
12,
1,
"VAE"
],
[
14,
12,
0,
13,
0,
"LATENT"
],
[
16,
13,
0,
3,
3,
"LATENT"
],
[
21,
4,
0,
18,
0,
"MODEL"
],
[
22,
18,
0,
3,
0,
"MODEL"
],
[
23,
19,
0,
13,
1,
"MASK"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.683013455365071,
"offset": [
146.55242134412282,
32.659636363636494
]
},
"frontendVersion": "1.34.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- Paint each area you want to change with a different shade (for example, light gray for the face and white for the background)
Soften the Boundaries
A common problem with inpainting is a clearly visible mask boundary.
Combine Differential Diffusion with a blurred mask to blend the boundary more naturally.

{
"id": "8b9f7796-0873-4025-be3c-0f997f67f866",
"revision": 0,
"last_node_id": 26,
"last_link_id": 37,
"nodes": [
{
"id": 9,
"type": "SaveImage",
"pos": [
1773.2999999999997,
213.20000000000002
],
"size": [
503.2876035004722,
576.239673217884
],
"flags": {},
"order": 12,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 8,
"type": "VAEDecode",
"pos": [
1531.2999999999997,
212.20000000000002
],
"size": [
203.39999999999986,
46
],
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 7
},
{
"name": "vae",
"type": "VAE",
"link": 10
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
416.1970166015625,
392.37848510742185
],
"size": [
410.75801513671877,
158.82607910156253
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 5
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
26
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"text, watermark, worst quality"
]
},
{
"id": 10,
"type": "VAELoader",
"pos": [
595.4674284324961,
604.8385752753561
],
"size": [
231.48760330578511,
58
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
10,
27
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"vae-ft-mse-840000-ema-pruned.safetensors"
]
},
{
"id": 23,
"type": "GrowMask",
"pos": [
383.9960038422341,
782.5591360982014
],
"size": [
210,
82
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 31
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
33
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "GrowMask"
},
"widgets_values": [
10,
true
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 26,
"type": "DifferentialDiffusion",
"pos": [
911.9888354376291,
91.96613864265017
],
"size": [
210,
58
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 36
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
37
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "DifferentialDiffusion"
},
"widgets_values": [
1
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
415,
186
],
"size": [
411.95503173828126,
151.0030493164063
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 3
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
25
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"high quality, RAW photo of a glass of cola. A glass with water droplets on it.\n"
]
},
{
"id": 3,
"type": "KSampler",
"pos": [
1185.2999999999995,
210.20000000000002
],
"size": [
315,
262
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 37
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 23
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 24
},
{
"name": "latent_image",
"type": "LATENT",
"link": 28
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"slot_index": 0,
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "KSampler"
},
"widgets_values": [
1234,
"fixed",
20,
8,
"euler",
"normal",
1
]
},
{
"id": 25,
"type": "ImpactGaussianBlurMask",
"pos": [
616.9550317382811,
783.3663338181777
],
"size": [
210,
82
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 33
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
32,
34
]
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "61bd8397a18e7e7668e6a24e95168967768c2bed",
"Node name for S&R": "ImpactGaussianBlurMask"
},
"widgets_values": [
30,
10
],
"color": "#432",
"bgcolor": "#653"
},
{
"id": 24,
"type": "MaskPreview",
"pos": [
859.5925016752453,
786.4859030229644
],
"size": [
296.28740796393686,
258
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 32
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "MaskPreview"
},
"widgets_values": []
},
{
"id": 22,
"type": "LoadImage",
"pos": [
12.38845236664146,
714.6602606311046
],
"size": [
348.6485235795455,
444.65055454545484
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
35
]
},
{
"name": "MASK",
"type": "MASK",
"links": [
31
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImage",
"image": "clipspace/clipspace-painted-masked-1765087764033.png [input]"
},
"widgets_values": [
"clipspace/clipspace-painted-masked-1765087764033.png [input]",
"image"
]
},
{
"id": 4,
"type": "CheckpointLoaderSimple",
"pos": [
39.900463636363625,
349.9095500000008
],
"size": [
315,
98
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"slot_index": 0,
"links": [
36
]
},
{
"name": "CLIP",
"type": "CLIP",
"slot_index": 1,
"links": [
3,
5
]
},
{
"name": "VAE",
"type": "VAE",
"slot_index": 2,
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"sd-v1-5-inpainting.ckpt"
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 20,
"type": "InpaintModelConditioning",
"pos": [
885.5197492645148,
229.90120706804433
],
"size": [
258.49395533092,
138
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "positive",
"type": "CONDITIONING",
"link": 25
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 26
},
{
"name": "vae",
"type": "VAE",
"link": 27
},
{
"name": "pixels",
"type": "IMAGE",
"link": 35
},
{
"name": "mask",
"type": "MASK",
"link": 34
}
],
"outputs": [
{
"name": "positive",
"type": "CONDITIONING",
"links": [
23
]
},
{
"name": "negative",
"type": "CONDITIONING",
"links": [
24
]
},
{
"name": "latent",
"type": "LATENT",
"links": [
28
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "InpaintModelConditioning"
},
"widgets_values": [
true
],
"color": "#323",
"bgcolor": "#535"
}
],
"links": [
[
3,
4,
1,
6,
0,
"CLIP"
],
[
5,
4,
1,
7,
0,
"CLIP"
],
[
7,
3,
0,
8,
0,
"LATENT"
],
[
9,
8,
0,
9,
0,
"IMAGE"
],
[
10,
10,
0,
8,
1,
"VAE"
],
[
23,
20,
0,
3,
1,
"CONDITIONING"
],
[
24,
20,
1,
3,
2,
"CONDITIONING"
],
[
25,
6,
0,
20,
0,
"CONDITIONING"
],
[
26,
7,
0,
20,
1,
"CONDITIONING"
],
[
27,
10,
0,
20,
2,
"VAE"
],
[
28,
20,
2,
3,
3,
"LATENT"
],
[
31,
22,
1,
23,
0,
"MASK"
],
[
32,
25,
0,
24,
0,
"MASK"
],
[
33,
23,
0,
25,
0,
"MASK"
],
[
34,
25,
0,
20,
4,
"MASK"
],
[
35,
22,
0,
20,
3,
"IMAGE"
],
[
36,
4,
0,
26,
0,
"MODEL"
],
[
37,
26,
0,
3,
0,
"MODEL"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.7513148009015783,
"offset": [
87.61154763335854,
8.033861357349835
]
},
"frontendVersion": "1.34.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 🟪 This time, incorporate it into a workflow using an inpainting model.
- 🟨 Blur the mask boundary with the
Gaussian Blur Masknode (ComfyUI-Impact-Pack)- Blurring effectively shrinks the mask, so enlarge it slightly beforehand.
Use a Depth Map as a Mask
A depth map is represented as a black-to-white gradient.
This means it can be used directly as a Differential Diffusion mask.

{
"id": "8b9f7796-0873-4025-be3c-0f997f67f866",
"revision": 0,
"last_node_id": 30,
"last_link_id": 50,
"nodes": [
{
"id": 8,
"type": "VAEDecode",
"pos": [
1531.2999999999997,
212.20000000000002
],
"size": [
203.39999999999986,
46
],
"flags": {},
"order": 13,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 7
},
{
"name": "vae",
"type": "VAE",
"link": 10
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
9
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "VAEDecode"
},
"widgets_values": []
},
{
"id": 10,
"type": "VAELoader",
"pos": [
595.4674284324961,
604.8385752753561
],
"size": [
231.48760330578511,
58
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
10,
27
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"vae-ft-mse-840000-ema-pruned.safetensors"
]
},
{
"id": 26,
"type": "DifferentialDiffusion",
"pos": [
911.9888354376291,
91.96613864265017
],
"size": [
210,
58
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 36
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
37
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "DifferentialDiffusion"
},
"widgets_values": [
1
],
"color": "#232",
"bgcolor": "#353"
},
{
"id": 4,
"type": "CheckpointLoaderSimple",
"pos": [
39.900463636363625,
349.9095500000008
],
"size": [
315,
98
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"slot_index": 0,
"links": [
36
]
},
{
"name": "CLIP",
"type": "CLIP",
"slot_index": 1,
"links": [
3,
5
]
},
{
"name": "VAE",
"type": "VAE",
"slot_index": 2,
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CheckpointLoaderSimple"
},
"widgets_values": [
"sd-v1-5-inpainting.ckpt"
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 9,
"type": "SaveImage",
"pos": [
1773.2999999999997,
213.20000000000002
],
"size": [
681.4876035004725,
577.339673217884
],
"flags": {},
"order": 14,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33"
},
"widgets_values": [
"ComfyUI"
]
},
{
"id": 22,
"type": "LoadImage",
"pos": [
-372.39154763335796,
567.1202606311042
],
"size": [
348.6485235795455,
444.65055454545484
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
35,
38
]
},
{
"name": "MASK",
"type": "MASK",
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "LoadImage",
"image": "clipspace/clipspace-painted-masked-1765087764033.png [input]"
},
"widgets_values": [
"pasted/image (46).png",
"image"
]
},
{
"id": 28,
"type": "ImageToMask",
"pos": [
242.37278607894345,
724.0115675875168
],
"size": [
210,
58
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 39
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
46
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "ImageToMask"
},
"widgets_values": [
"red"
]
},
{
"id": 29,
"type": "InvertMask",
"pos": [
463.6676231181421,
724.9477989676396
],
"size": [
140,
26
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 46
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [
48
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "InvertMask"
},
"widgets_values": []
},
{
"id": 20,
"type": "InpaintModelConditioning",
"pos": [
885.5197492645148,
229.90120706804433
],
"size": [
258.49395533092,
138
],
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "positive",
"type": "CONDITIONING",
"link": 25
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 26
},
{
"name": "vae",
"type": "VAE",
"link": 27
},
{
"name": "pixels",
"type": "IMAGE",
"link": 35
},
{
"name": "mask",
"type": "MASK",
"link": 50
}
],
"outputs": [
{
"name": "positive",
"type": "CONDITIONING",
"links": [
23
]
},
{
"name": "negative",
"type": "CONDITIONING",
"links": [
24
]
},
{
"name": "latent",
"type": "LATENT",
"links": [
28
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "InpaintModelConditioning"
},
"widgets_values": [
true
],
"color": "#323",
"bgcolor": "#535"
},
{
"id": 24,
"type": "MaskPreview",
"pos": [
863.712501675244,
720.3897046758566
],
"size": [
296.28740796393686,
258
],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 49
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.76",
"Node name for S&R": "MaskPreview"
},
"widgets_values": []
},
{
"id": 7,
"type": "CLIPTextEncode",
"pos": [
416.1970166015625,
392.37848510742185
],
"size": [
410.75801513671877,
158.82607910156253
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 5
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
26
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"low quality, worst quality, blurry, out of focus, deformed face, distorted body, extra limbs, extra legs, extra arms, duplicate people, text, watermark, logo, frame, monochrome, black and white"
]
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": [
415,
186
],
"size": [
411.95503173828126,
151.0030493164063
],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 3
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"slot_index": 0,
"links": [
25
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"(best quality, high quality, detailed),beautifull woman walking to viewer, city transformed into a colorful floral scene, (vivid colors:1.1), blooming flowers growing from windows and walls,35mm lens, realistic lighting, ultra detailed, photorealistic"
]
},
{
"id": 30,
"type": "RemapMaskRange",
"pos": [
618.4611687276335,
725.6004563565681
],
"size": [
210,
82
],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 48
}
],
"outputs": [
{
"name": "mask",
"type": "MASK",
"links": [
49,
50
]
}
],
"properties": {
"cnr_id": "comfyui-kjnodes",
"ver": "4dfb85dcc52e4315c33170d97bb987baa46d128b",
"Node name for S&R": "RemapMaskRange"
},
"widgets_values": [
-0.3,
1.6
]
},
{
"id": 27,
"type": "DepthAnythingV2Preprocessor",
"pos": [
2.3412432757320483,
721.9022295517397
],
"size": [
219.6646484375,
82
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 38
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
39
]
}
],
"properties": {
"cnr_id": "comfyui_controlnet_aux",
"ver": "12f35647f0d510e03b45a47fb420fe1245a575df",
"Node name for S&R": "DepthAnythingV2Preprocessor"
},
"widgets_values": [
"depth_anything_v2_vitl.pth",
512
],
"color": "#223",
"bgcolor": "#335"
},
{
"id": 3,
"type": "KSampler",
"pos": [
1185.2999999999995,
210.20000000000002
],
"size": [
315,
262
],
"flags": {},
"order": 12,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 37
},
{
"name": "positive",
"type": "CONDITIONING",
"link": 23
},
{
"name": "negative",
"type": "CONDITIONING",
"link": 24
},
{
"name": "latent_image",
"type": "LATENT",
"link": 28
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"slot_index": 0,
"links": [
7
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.33",
"Node name for S&R": "KSampler"
},
"widgets_values": [
987,
"fixed",
20,
8,
"euler",
"normal",
1
]
}
],
"links": [
[
3,
4,
1,
6,
0,
"CLIP"
],
[
5,
4,
1,
7,
0,
"CLIP"
],
[
7,
3,
0,
8,
0,
"LATENT"
],
[
9,
8,
0,
9,
0,
"IMAGE"
],
[
10,
10,
0,
8,
1,
"VAE"
],
[
23,
20,
0,
3,
1,
"CONDITIONING"
],
[
24,
20,
1,
3,
2,
"CONDITIONING"
],
[
25,
6,
0,
20,
0,
"CONDITIONING"
],
[
26,
7,
0,
20,
1,
"CONDITIONING"
],
[
27,
10,
0,
20,
2,
"VAE"
],
[
28,
20,
2,
3,
3,
"LATENT"
],
[
35,
22,
0,
20,
3,
"IMAGE"
],
[
36,
4,
0,
26,
0,
"MODEL"
],
[
37,
26,
0,
3,
0,
"MODEL"
],
[
38,
22,
0,
27,
0,
"IMAGE"
],
[
39,
27,
0,
28,
0,
"IMAGE"
],
[
46,
28,
0,
29,
0,
"MASK"
],
[
48,
29,
0,
30,
0,
"MASK"
],
[
49,
30,
0,
24,
0,
"MASK"
],
[
50,
30,
0,
20,
4,
"MASK"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.6830134553650705,
"offset": [
472.39154763335796,
8.033861357349835
]
},
"frontendVersion": "1.34.6",
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true
},
"version": 0.4
}
- 🟦 Create a depth map with Depth Anything V2 (comfyui_controlnet_aux)
- The output is an IMAGE, so convert it to a mask with the
Convert Image to Masknode.
- The output is an IMAGE, so convert it to a mask with the
- Adjust its range with
RemapMaskRange(ComfyUI-KJNodes)
Honestly, SD1.5 is not quite capable enough, but using a depth map as a mask is still one of my favorite methods.
Sample Images



