얼굴 교체
사진에서 즉시 AI 얼굴 교체를 지원하는 최고의 기술.
워크플로 내부
소스 템플릿의 읽기 전용 미리보기입니다. Cloud에서 열어 노드를 살펴보고 변경할 수 있습니다.
Loading the graph
Open full-size workflow preview코드에서 이 모델 호출하기
아래 요청은 Playground와 동일하게 준비된 그래프와 설정을 사용합니다. 제출할 때마다 유료 실행이 시작될 수 있으므로 결과를 알 수 없는 제출을 자동으로 재시도하지 마세요.
What you need
- Runs on
- Comfy Cloud
- 키
- COMFY_API_KEY
- 내 파일
- 코드가 해당 URL에서 업로드
유료 Cloud 요금제와 크레딧이 필요합니다.
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"76": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_base_image_FILENAME"
},
"_meta": {
"title": "Load Target Image"
}
},
"81": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_head_image_FILENAME"
},
"_meta": {
"title": "Load Source Image"
}
},
"190": {
"class_type": "ImageCompare",
"inputs": {
"compare_view": {
"__value__": [
"",
""
]
},
"image_a": [
"204",
0
],
"image_b": [
"199:120",
0
]
},
"_meta": {
"title": "Compare Images"
}
},
"204": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "face_swap",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"199:131",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"205": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "face_swap_stitched",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"199:177",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"199:109": {
"class_type": "SamplerCustomAdvanced",
"inputs": {
"guider": [
"199:123",
0
],
"latent_image": [
"199:113",
0
],
"noise": [
"199:110",
0
],
"sampler": [
"199:125",
0
],
"sigmas": [
"199:122",
0
]
},
"_meta": {
"title": "SamplerCustomAdvanced"
}
},
"199:110": {
"class_type": "RandomNoise",
"inputs": {
"noise_seed": 788122026421577
},
"_meta": {
"title": "RandomNoise"
}
},
"199:111": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "flux2-vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"199:112": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"199:120",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"199:113": {
"class_type": "EmptyFlux2LatentImage",
"inputs": {
"batch_size": 1,
"height": [
"199:112",
1
],
"width": [
"199:112",
0
]
},
"_meta": {
"title": "Empty Flux 2 Latent"
}
},
"199:114:179": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"199:116:180",
0
],
"latent": [
"199:114:78",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"199:114:77": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"199:116:182",
0
],
"latent": [
"199:114:78",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"199:114:78": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"199:121",
0
],
"vae": [
"199:111",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"199:115": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_3_8b_fp8mixed.safetensors",
"device": "default",
"type": "flux2"
},
"_meta": {
"title": "Load CLIP"
}
},
"199:116:180": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"199:119",
0
],
"latent": [
"199:116:181",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"199:116:181": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"199:120",
0
],
"vae": [
"199:111",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"199:116:182": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"199:117",
0
],
"latent": [
"199:116:181",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"199:117": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"199:115",
0
],
"text": [
"199:198",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"199:118": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "flux-2-klein-9b.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"199:119": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"199:115",
0
],
"text": "bad quality, noise, blurry, worst quality, low resolution, blur, distortion, unnatural blending, cartoon, illustration, painting"
},
"_meta": {
"title": "CLIP Text Encode ( Negative Prompt)"
}
},
"199:120": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"76",
0
],
"resize_type": "scale total pixels",
"resize_type.megapixels": 1,
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"199:121": {
"class_type": "ResizeImageMaskNode",
"inputs": {
"input": [
"81",
0
],
"resize_type": "scale total pixels",
"resize_type.megapixels": 1,
"scale_method": "lanczos"
},
"_meta": {
"title": "Resize Image/Mask"
}
},
"199:122": {
"class_type": "Flux2Scheduler",
"inputs": {
"height": [
"199:112",
1
],
"steps": 4,
"width": [
"199:112",
0
]
},
"_meta": {
"title": "Flux2Scheduler"
}
},
"199:123": {
"class_type": "CFGGuider",
"inputs": {
"cfg": 1,
"model": [
"199:133",
0
],
"negative": [
"199:114:179",
0
],
"positive": [
"199:114:77",
0
]
},
"_meta": {
"title": "CFG Guider"
}
},
"199:125": {
"class_type": "KSamplerSelect",
"inputs": {
"sampler_name": "lcm"
},
"_meta": {
"title": "KSamplerSelect"
}
},
"199:131": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"199:109",
0
],
"vae": [
"199:111",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"199:133": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Alissonerdx__BFS-Best-Face-Swap__bfs_head_v1_flux-klein_9b_step3750_rank64.safetensors",
"model": [
"199:118",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"199:171": {
"class_type": "StringConcatenate",
"inputs": {
"delimiter": "",
"string_a": [
"199:197",
0
],
"string_b": [
"199:184",
0
]
},
"_meta": {
"title": "Concatenate Prompt"
}
},
"199:176": {
"class_type": "ImageConcanate",
"inputs": {
"direction": "down",
"image1": [
"199:120",
0
],
"image2": [
"199:121",
0
],
"match_image_size": True
},
"_meta": {
"title": "ImageConcanate"
}
},
"199:177": {
"class_type": "ImageConcanate",
"inputs": {
"direction": "right",
"image1": [
"199:176",
0
],
"image2": [
"199:131",
0
],
"match_image_size": True
},
"_meta": {
"title": "ImageConcanate"
}
},
"199:184": {
"class_type": "TextGenerate",
"inputs": {
"clip": [
"199:185",
0
],
"image": [
"199:120",
0
],
"max_length": 256,
"mtp": "auto",
"prompt": "Describe the facial expression. Do not mention facial details such as freckles or unique marks. Do not output <think> tags.\n\nAn example output is as follows:\n<example>\nKey features include:\n- A wide, open-mouthed grin with their tongue sticking out playfully.\n- One eye is winking (the right eye), adding to the mischievous or fun vibe.\n- Their lips are parted in an exaggerated smile that complements the tongue-out gesture.\n- The overall look conveys confidence, joy, and a sense of youthful rebellion — perfectly matching the vibrant, colorful aesthetic they’re presenting.\n</<example>",
"sampling_mode": "on",
"sampling_mode.min_p": 0.05,
"sampling_mode.presence_penalty": 0,
"sampling_mode.repetition_penalty": 1.05,
"sampling_mode.seed": 1,
"sampling_mode.temperature": 0.7,
"sampling_mode.top_k": 64,
"sampling_mode.top_p": 0.95,
"thinking": False,
"use_default_template": True
},
"_meta": {
"title": "Generate Text"
}
},
"199:185": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen3.5_9b_bf16.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"199:195": {
"class_type": "ComfySwitchNode",
"inputs": {
"on_false": [
"199:197",
0
],
"on_true": [
"199:171",
0
],
"switch": True
},
"_meta": {
"title": "If/Else Switch"
}
},
"199:197": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "head_swap: start with Picture 1 as the base image, keeping its lighting, environment, and background. remove the head from Picture 1 completely and replace it with the head from Picture 2, strictly preserving the hair, eye color, nose structure of Picture 2. copy the direction of the eye, head rotation, micro expressions from Picture 1, high quality, sharp details, 4k\n"
},
"_meta": {
"title": "Prompt Base"
}
},
"199:198": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"199:195",
0
]
},
"_meta": {
"title": "Preview as Text"
}
}
})
workflow.set_input("76", "image", client.assets.from_url("https://comfy.org/catalog-media/8fe73d3d-d1b4-441f-868f-de7c39283e4b/e7eb0cc0-e6b4-435e-be2f-9b834c6d4fb9"))
workflow.set_input("81", "image", client.assets.from_url("https://comfy.org/catalog-media/24509314-ef4a-4dee-af38-c8602e8f38dc/6b898242-c7e9-4f34-9ac3-b0e9abd51ff2"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("204"):
output.to_file(output.name)
for output in job.get_outputs("205"):
output.to_file(output.name)예시 사용해 보기
이 워크플로 정보
이 ComfyUI 워크플로는 최소 구성의 튜닝하기 쉬운 그래프로 사진에서 빠르고 고품질의 얼굴 교체를 수행합니다. 두 개의 LoadImage 노드로 소스 얼굴(전달할 정체성)과 대상 사진을 불러옵니다. 커스텀 얼굴 교체 프로세서(노드 ID: 217f3726-59bc-4170-9ab1-c622bb578338)가 대상에서 얼굴을 감지하고 정렬한 다음, 표정/포즈/조명을 유지하면서 소스 정체성을 대상에 전송해 합성 이미지를 출력합니다. ImageCompare 노드는 원본과 결과를 시각적으로 비교해 빠른 A/B 확인을 가능하게 하며, SaveImageAdvanced는 깔끔하고 반복 가능한 내보내기를 처리합니다.
기술적으로 얼굴 교체 노드는 얼굴 감지, 정렬/워핑, 정체성 전송, 블렌딩이라는 핵심 파이프라인을 캡슐화하므로, 별도의 감지 또는 마스킹 노드를 관리할 필요가 없습니다. 그 결과 워크플로가 컴팩트하고 견고해집니다. 이미지를 로드하고, 구현에 따라 가능한 설정(여러 얼굴 중 교체 대상 선택, 블렌드 강도 등)을 필요에 맞게 조정한 뒤, ImageCompare로 미리보고, SaveImageAdvanced로 일관된 이름/형식으로 저장하면 됩니다. 큰 복잡한 그래프를 만들지 않고도 좋은 입력 사진에서 안정적인 얼굴 교체가 필요할 때 특히 유용합니다.
질문과 답변
얼굴이 선명하고 가려짐이 적으며 조명이 좋은 이미지를 사용하세요. 정면 또는 약간의 3/4 각도가 가장 좋습니다. 손/머리/마스크 등 심한 가림, 극단적인 측면, 모션 블러는 결과를 저하시킬 수 있습니다.
얼굴 교체 노드(217f3726-59bc-4170-9ab1-c622bb578338)를 엽니다. 얼굴 선택 컨트롤이 있다면 교체할 인덱스/얼굴을 선택하세요. 없다면 대상 이미지를 의도한 얼굴 주변으로 크롭해 다시 실행하세요.
소스와 대상의 조명이나 색상 차이가 크면 블렌딩에서 드러날 수 있습니다. 조명과 톤이 비슷한 소스 사진을 사용하거나, 기본적인 색상/대비 조정으로 전처리해 보세요. 가능한 경우 얼굴 교체 노드의 블렌드/feather를 미세 조정하는 것도 도움이 됩니다.
아니오. 이 워크플로는 새로운 교체 이미지를 생성합니다. SaveImageAdvanced로 선택한 형식, 품질, 파일 이름 패턴으로 비파괴적으로 내보낼 수 있습니다.
관련 워크플로
- Nano Banana Pro, Gemini3 Pro Image Preview, Google
Create a character turnaround
- Qwen-Image-Edit
Change a material
- Qwen-Image-Edit
See your subject from a new angle
- Flux.2 Dev, Flux
Create a product mockup
- Nano Banana Pro
Try an outfit on a character
- Seedream
Put your product in a new scene
- SSeedVR2
Upscale and restore detail
- Nano Banana Pro
Sharpen a product photo
- Topaz
Upscale an illustration
- HHitPaw
Restore portrait detail
- FLUX.1 Fill
Edit a selected region
- FLUX.1 Fill
Extend an image’s borders