ComfyUI

使用方法

工作流

局部遮罩,替换背景

image-20240423112732468

IPAdapter + ControlNet 前景背景替换 comfyUI工作流

升级版,可通过节点获取遮罩

{
  "last_node_id": 35,
  "last_link_id": 59,
  "nodes": [
    {
      "id": 8,
      "type": "VAEDecode",
      "pos": [
        1209,
        188
      ],
      "size": {
        "0": 210,
        "1": 46
      },
      "flags": {},
      "order": 27,
      "mode": 0,
      "inputs": [
        {
          "name": "samples",
          "type": "LATENT",
          "link": 7
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 8
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            9
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "VAEDecode"
      }
    },
    {
      "id": 10,
      "type": "LoadImage",
      "pos": [
        23,
        805
      ],
      "size": {
        "0": 315,
        "1": 314.0000305175781
      },
      "flags": {},
      "order": 0,
      "mode": 0,
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            10
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "MASK",
          "type": "MASK",
          "links": null,
          "shape": 3
        }
      ],
      "properties": {
        "Node name for S&R": "LoadImage"
      },
      "widgets_values": [
        "ComfyUI_00686_.png",
        "image"
      ]
    },
    {
      "id": 7,
      "type": "CLIPTextEncode",
      "pos": [
        413,
        389
      ],
      "size": {
        "0": 425.27801513671875,
        "1": 180.6060791015625
      },
      "flags": {},
      "order": 11,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 5
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            15
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        "text, watermark"
      ]
    },
    {
      "id": 23,
      "type": "IPAdapterUnifiedLoader",
      "pos": [
        176,
        -148
      ],
      "size": {
        "0": 315,
        "1": 78
      },
      "flags": {},
      "order": 9,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 32
        },
        {
          "name": "ipadapter",
          "type": "IPADAPTER",
          "link": null
        }
      ],
      "outputs": [
        {
          "name": "model",
          "type": "MODEL",
          "links": [
            30
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "ipadapter",
          "type": "IPADAPTER",
          "links": [
            31
          ],
          "shape": 3,
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "IPAdapterUnifiedLoader"
      },
      "widgets_values": [
        "PLUS (high strength)"
      ]
    },
    {
      "id": 30,
      "type": "PreviewImage",
      "pos": [
        1820,
        1472
      ],
      "size": {
        "0": 210,
        "1": 246
      },
      "flags": {},
      "order": 22,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 39
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 31,
      "type": "MaskPreview+",
      "pos": [
        1590,
        1604
      ],
      "size": {
        "0": 210,
        "1": 246
      },
      "flags": {},
      "order": 23,
      "mode": 0,
      "inputs": [
        {
          "name": "mask",
          "type": "MASK",
          "link": 40
        }
      ],
      "properties": {
        "Node name for S&R": "MaskPreview+"
      }
    },
    {
      "id": 26,
      "type": "SAMLoader",
      "pos": [
        1190,
        1460
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 1,
      "mode": 0,
      "outputs": [
        {
          "name": "SAM_MODEL",
          "type": "SAM_MODEL",
          "links": [
            35
          ],
          "shape": 3
        }
      ],
      "properties": {
        "Node name for S&R": "SAMLoader"
      },
      "widgets_values": [
        "sam_vit_b_01ec64.pth",
        "AUTO"
      ]
    },
    {
      "id": 32,
      "type": "SAM Parameters",
      "pos": [
        1193,
        1597
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 2,
      "mode": 0,
      "outputs": [
        {
          "name": "SAM_PARAMETERS",
          "type": "SAM_PARAMETERS",
          "links": [
            42
          ],
          "shape": 3
        }
      ],
      "properties": {
        "Node name for S&R": "SAM Parameters"
      },
      "widgets_values": [
        "[1024, 1024]; [0, 0]",
        "[2, 4]"
      ]
    },
    {
      "id": 21,
      "type": "PreviewImage",
      "pos": [
        1916,
        838
      ],
      "size": {
        "0": 210,
        "1": 246
      },
      "flags": {},
      "order": 18,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 29
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 24,
      "type": "LoadImage",
      "pos": [
        49,
        -3
      ],
      "size": {
        "0": 315,
        "1": 314
      },
      "flags": {},
      "order": 3,
      "mode": 0,
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            33
          ],
          "shape": 3
        },
        {
          "name": "MASK",
          "type": "MASK",
          "links": null,
          "shape": 3
        }
      ],
      "properties": {
        "Node name for S&R": "LoadImage"
      },
      "widgets_values": [
        "eab5cf21d7834d9a92f736fda598c861 (1).jpeg",
        "image"
      ]
    },
    {
      "id": 14,
      "type": "PreviewImage",
      "pos": [
        829,
        948
      ],
      "size": {
        "0": 210,
        "1": 246
      },
      "flags": {},
      "order": 16,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 13
        }
      ],
      "properties": {
        "Node name for S&R": "PreviewImage"
      }
    },
    {
      "id": 5,
      "type": "EmptyLatentImage",
      "pos": [
        473,
        609
      ],
      "size": {
        "0": 315,
        "1": 106
      },
      "flags": {},
      "order": 4,
      "mode": 0,
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [],
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "EmptyLatentImage"
      },
      "widgets_values": [
        1024,
        1024,
        1
      ]
    },
    {
      "id": 19,
      "type": "RemBGSession+",
      "pos": [
        1179,
        1139
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 5,
      "mode": 0,
      "outputs": [
        {
          "name": "REMBG_SESSION",
          "type": "REMBG_SESSION",
          "links": [
            22
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "RemBGSession+"
      },
      "widgets_values": [
        "isnet-general-use: general purpose",
        "CPU"
      ]
    },
    {
      "id": 6,
      "type": "CLIPTextEncode",
      "pos": [
        415,
        186
      ],
      "size": {
        "0": 422.84503173828125,
        "1": 164.31304931640625
      },
      "flags": {},
      "order": 10,
      "mode": 0,
      "inputs": [
        {
          "name": "clip",
          "type": "CLIP",
          "link": 3
        }
      ],
      "outputs": [
        {
          "name": "CONDITIONING",
          "type": "CONDITIONING",
          "links": [
            14
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "CLIPTextEncode"
      },
      "widgets_values": [
        "a (tiger:0.7) made of flower, high quality, highly detailed, 4k"
      ]
    },
    {
      "id": 33,
      "type": "DifferentialDiffusion",
      "pos": [
        909,
        -127
      ],
      "size": {
        "0": 210,
        "1": 26
      },
      "flags": {},
      "order": 24,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 43
        }
      ],
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            44
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "DifferentialDiffusion"
      }
    },
    {
      "id": 13,
      "type": "DepthAnythingPreprocessor",
      "pos": [
        824,
        798
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 12,
      "mode": 0,
      "inputs": [
        {
          "name": "image",
          "type": "IMAGE",
          "link": 12
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            13,
            16
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "DepthAnythingPreprocessor"
      },
      "widgets_values": [
        "depth_anything_vitl14.pth",
        1024
      ]
    },
    {
      "id": 11,
      "type": "ImageResize+",
      "pos": [
        472,
        810
      ],
      "size": {
        "0": 315,
        "1": 218
      },
      "flags": {},
      "order": 8,
      "mode": 0,
      "inputs": [
        {
          "name": "image",
          "type": "IMAGE",
          "link": 10
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            12,
            21,
            23,
            41
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "width",
          "type": "INT",
          "links": null,
          "shape": 3
        },
        {
          "name": "height",
          "type": "INT",
          "links": null,
          "shape": 3
        }
      ],
      "properties": {
        "Node name for S&R": "ImageResize+"
      },
      "widgets_values": [
        1024,
        0,
        "nearest",
        true,
        "always",
        0
      ]
    },
    {
      "id": 9,
      "type": "SaveImage",
      "pos": [
        1473,
        189
      ],
      "size": {
        "0": 210,
        "1": 270
      },
      "flags": {},
      "order": 28,
      "mode": 0,
      "inputs": [
        {
          "name": "images",
          "type": "IMAGE",
          "link": 9
        }
      ],
      "properties": {},
      "widgets_values": [
        "ComfyUI"
      ]
    },
    {
      "id": 3,
      "type": "KSampler",
      "pos": [
        869,
        199
      ],
      "size": {
        "0": 315,
        "1": 262
      },
      "flags": {},
      "order": 26,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 44
        },
        {
          "name": "positive",
          "type": "CONDITIONING",
          "link": 56
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "link": 57
        },
        {
          "name": "latent_image",
          "type": "LATENT",
          "link": 58
        }
      ],
      "outputs": [
        {
          "name": "LATENT",
          "type": "LATENT",
          "links": [
            7
          ],
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "KSampler"
      },
      "widgets_values": [
        920127454916620,
        "fixed",
        30,
        8,
        "dpmpp_2m",
        "karras",
        1
      ]
    },
    {
      "id": 22,
      "type": "IPAdapterAdvanced",
      "pos": [
        520,
        -154
      ],
      "size": {
        "0": 315,
        "1": 278
      },
      "flags": {},
      "order": 15,
      "mode": 0,
      "inputs": [
        {
          "name": "model",
          "type": "MODEL",
          "link": 30,
          "slot_index": 0
        },
        {
          "name": "ipadapter",
          "type": "IPADAPTER",
          "link": 31
        },
        {
          "name": "image",
          "type": "IMAGE",
          "link": 33,
          "slot_index": 2
        },
        {
          "name": "image_negative",
          "type": "IMAGE",
          "link": null
        },
        {
          "name": "attn_mask",
          "type": "MASK",
          "link": null
        },
        {
          "name": "clip_vision",
          "type": "CLIP_VISION",
          "link": null
        }
      ],
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            43
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "IPAdapterAdvanced"
      },
      "widgets_values": [
        1,
        "linear",
        "concat",
        0,
        1,
        "V only"
      ]
    },
    {
      "id": 20,
      "type": "MaskPreview+",
      "pos": [
        1897,
        1152
      ],
      "size": {
        "0": 210,
        "1": 246
      },
      "flags": {},
      "order": 19,
      "mode": 0,
      "inputs": [
        {
          "name": "mask",
          "type": "MASK",
          "link": 24
        }
      ],
      "properties": {
        "Node name for S&R": "MaskPreview+"
      }
    },
    {
      "id": 34,
      "type": "GrowMask",
      "pos": [
        1549,
        992
      ],
      "size": {
        "0": 315,
        "1": 82
      },
      "flags": {},
      "order": 21,
      "mode": 0,
      "inputs": [
        {
          "name": "mask",
          "type": "MASK",
          "link": 59
        }
      ],
      "outputs": [
        {
          "name": "MASK",
          "type": "MASK",
          "links": [
            55
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "GrowMask"
      },
      "widgets_values": [
        5,
        true
      ]
    },
    {
      "id": 35,
      "type": "InvertMask",
      "pos": [
        1531,
        1285
      ],
      "size": {
        "0": 210,
        "1": 26
      },
      "flags": {},
      "order": 20,
      "mode": 0,
      "inputs": [
        {
          "name": "mask",
          "type": "MASK",
          "link": 49
        }
      ],
      "outputs": [
        {
          "name": "MASK",
          "type": "MASK",
          "links": [],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "InvertMask"
      }
    },
    {
      "id": 25,
      "type": "SAM Image Mask",
      "pos": [
        1546,
        1466
      ],
      "size": {
        "0": 254.40000915527344,
        "1": 66
      },
      "flags": {},
      "order": 14,
      "mode": 0,
      "inputs": [
        {
          "name": "sam_model",
          "type": "SAM_MODEL",
          "link": 35,
          "slot_index": 0
        },
        {
          "name": "sam_parameters",
          "type": "SAM_PARAMETERS",
          "link": 42,
          "slot_index": 1
        },
        {
          "name": "image",
          "type": "IMAGE",
          "link": 41
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            39
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "MASK",
          "type": "MASK",
          "links": [
            40
          ],
          "shape": 3,
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "SAM Image Mask"
      }
    },
    {
      "id": 18,
      "type": "ImageRemoveBackground+",
      "pos": [
        1544,
        1143
      ],
      "size": {
        "0": 257.0208435058594,
        "1": 46
      },
      "flags": {},
      "order": 13,
      "mode": 0,
      "inputs": [
        {
          "name": "rembg_session",
          "type": "REMBG_SESSION",
          "link": 22,
          "slot_index": 0
        },
        {
          "name": "image",
          "type": "IMAGE",
          "link": 23
        }
      ],
      "outputs": [
        {
          "name": "IMAGE",
          "type": "IMAGE",
          "links": [
            29
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "MASK",
          "type": "MASK",
          "links": [
            24,
            49,
            59
          ],
          "shape": 3,
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "ImageRemoveBackground+"
      }
    },
    {
      "id": 16,
      "type": "ControlNetLoader",
      "pos": [
        1185,
        1014
      ],
      "size": {
        "0": 315,
        "1": 58
      },
      "flags": {},
      "order": 6,
      "mode": 0,
      "outputs": [
        {
          "name": "CONTROL_NET",
          "type": "CONTROL_NET",
          "links": [
            17
          ],
          "shape": 3,
          "slot_index": 0
        }
      ],
      "properties": {
        "Node name for S&R": "ControlNetLoader"
      },
      "widgets_values": [
        "control_v11f1p_sd15_depth_fp16.safetensors"
      ]
    },
    {
      "id": 17,
      "type": "InpaintModelConditioning",
      "pos": [
        1539,
        796
      ],
      "size": {
        "0": 216.59999084472656,
        "1": 106
      },
      "flags": {},
      "order": 25,
      "mode": 0,
      "inputs": [
        {
          "name": "positive",
          "type": "CONDITIONING",
          "link": 54
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "link": 19
        },
        {
          "name": "vae",
          "type": "VAE",
          "link": 20
        },
        {
          "name": "pixels",
          "type": "IMAGE",
          "link": 21
        },
        {
          "name": "mask",
          "type": "MASK",
          "link": 55
        }
      ],
      "outputs": [
        {
          "name": "positive",
          "type": "CONDITIONING",
          "links": [
            56
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "links": [
            57
          ],
          "shape": 3,
          "slot_index": 1
        },
        {
          "name": "latent",
          "type": "LATENT",
          "links": [
            58
          ],
          "shape": 3,
          "slot_index": 2
        }
      ],
      "properties": {
        "Node name for S&R": "InpaintModelConditioning"
      }
    },
    {
      "id": 15,
      "type": "ControlNetApplyAdvanced",
      "pos": [
        1170,
        794
      ],
      "size": {
        "0": 315,
        "1": 166
      },
      "flags": {},
      "order": 17,
      "mode": 0,
      "inputs": [
        {
          "name": "positive",
          "type": "CONDITIONING",
          "link": 14
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "link": 15
        },
        {
          "name": "control_net",
          "type": "CONTROL_NET",
          "link": 17,
          "slot_index": 2
        },
        {
          "name": "image",
          "type": "IMAGE",
          "link": 16
        }
      ],
      "outputs": [
        {
          "name": "positive",
          "type": "CONDITIONING",
          "links": [
            54
          ],
          "shape": 3,
          "slot_index": 0
        },
        {
          "name": "negative",
          "type": "CONDITIONING",
          "links": [
            19
          ],
          "shape": 3,
          "slot_index": 1
        }
      ],
      "properties": {
        "Node name for S&R": "ControlNetApplyAdvanced"
      },
      "widgets_values": [
        1,
        0,
        1
      ]
    },
    {
      "id": 4,
      "type": "CheckpointLoaderSimple",
      "pos": [
        44,
        402
      ],
      "size": {
        "0": 315,
        "1": 98
      },
      "flags": {},
      "order": 7,
      "mode": 0,
      "outputs": [
        {
          "name": "MODEL",
          "type": "MODEL",
          "links": [
            32
          ],
          "slot_index": 0
        },
        {
          "name": "CLIP",
          "type": "CLIP",
          "links": [
            3,
            5
          ],
          "slot_index": 1
        },
        {
          "name": "VAE",
          "type": "VAE",
          "links": [
            8,
            20
          ],
          "slot_index": 2
        }
      ],
      "properties": {
        "Node name for S&R": "CheckpointLoaderSimple"
      },
      "widgets_values": [
        "Deliberate_v4-inpainting.safetensors"
      ]
    }
  ],
  "links": [
    [
      3,
      4,
      1,
      6,
      0,
      "CLIP"
    ],
    [
      5,
      4,
      1,
      7,
      0,
      "CLIP"
    ],
    [
      7,
      3,
      0,
      8,
      0,
      "LATENT"
    ],
    [
      8,
      4,
      2,
      8,
      1,
      "VAE"
    ],
    [
      9,
      8,
      0,
      9,
      0,
      "IMAGE"
    ],
    [
      10,
      10,
      0,
      11,
      0,
      "IMAGE"
    ],
    [
      12,
      11,
      0,
      13,
      0,
      "IMAGE"
    ],
    [
      13,
      13,
      0,
      14,
      0,
      "IMAGE"
    ],
    [
      14,
      6,
      0,
      15,
      0,
      "CONDITIONING"
    ],
    [
      15,
      7,
      0,
      15,
      1,
      "CONDITIONING"
    ],
    [
      16,
      13,
      0,
      15,
      3,
      "IMAGE"
    ],
    [
      17,
      16,
      0,
      15,
      2,
      "CONTROL_NET"
    ],
    [
      19,
      15,
      1,
      17,
      1,
      "CONDITIONING"
    ],
    [
      20,
      4,
      2,
      17,
      2,
      "VAE"
    ],
    [
      21,
      11,
      0,
      17,
      3,
      "IMAGE"
    ],
    [
      22,
      19,
      0,
      18,
      0,
      "REMBG_SESSION"
    ],
    [
      23,
      11,
      0,
      18,
      1,
      "IMAGE"
    ],
    [
      24,
      18,
      1,
      20,
      0,
      "MASK"
    ],
    [
      29,
      18,
      0,
      21,
      0,
      "IMAGE"
    ],
    [
      30,
      23,
      0,
      22,
      0,
      "MODEL"
    ],
    [
      31,
      23,
      1,
      22,
      1,
      "IPADAPTER"
    ],
    [
      32,
      4,
      0,
      23,
      0,
      "MODEL"
    ],
    [
      33,
      24,
      0,
      22,
      2,
      "IMAGE"
    ],
    [
      35,
      26,
      0,
      25,
      0,
      "SAM_MODEL"
    ],
    [
      39,
      25,
      0,
      30,
      0,
      "IMAGE"
    ],
    [
      40,
      25,
      1,
      31,
      0,
      "MASK"
    ],
    [
      41,
      11,
      0,
      25,
      2,
      "IMAGE"
    ],
    [
      42,
      32,
      0,
      25,
      1,
      "SAM_PARAMETERS"
    ],
    [
      43,
      22,
      0,
      33,
      0,
      "MODEL"
    ],
    [
      44,
      33,
      0,
      3,
      0,
      "MODEL"
    ],
    [
      49,
      18,
      1,
      35,
      0,
      "MASK"
    ],
    [
      54,
      15,
      0,
      17,
      0,
      "CONDITIONING"
    ],
    [
      55,
      34,
      0,
      17,
      4,
      "MASK"
    ],
    [
      56,
      17,
      0,
      3,
      1,
      "CONDITIONING"
    ],
    [
      57,
      17,
      1,
      3,
      2,
      "CONDITIONING"
    ],
    [
      58,
      17,
      2,
      3,
      3,
      "LATENT"
    ],
    [
      59,
      18,
      1,
      34,
      0,
      "MASK"
    ]
  ],
  "groups": [],
  "config": {},
  "extra": {},
  "version": 0.4
}

IPAdapter + ControlNet 前景背景替换 comfyUI工作流 (youtube.com)

无损放大

  • 潜空间放大(改变的细节多一些)

image-20240424112719523

image-20240424112652937

  • 放大模型放大

    image-20240424113356519

图像混合

14.、ComfyUI图像合成、Clip分离精确控制Prompts_哔哩哔哩_bilibili

image-20240425111727792

Clip分离精确控制提示词(Prompts)

image-20240425112934799

两个Clip Text通过联结(Conditioning)

风格迁移

手绘涂鸦

采样器

image-20240425113750321

快捷键:Ctrl+M 关闭模块

关闭节点会阻断运行,忽略节点不会

posted @ 2026-07-05 14:38  挪威的straw  阅读(18)  评论(0)    收藏  举报