ComfyUI Node

头像替换

Swap a head onto a product shot without touching a brush

By MoJIeAIGC·Created about a year ago·Updated 17 days ago· 50
头像替换
  • source_head
  • replac_head
  • output
seed0

The classic e-commerce headache: you shot a model, the body is perfect, and the face is wrong - wrong expression, wrong person, or the client just wants a different head on the same outfit. Local ComfyUI has an entire stack for this (face LoRAs, IP-Adapter, inpainting), but it's fiddly and VRAM-hungry. This node offloads the whole job: feed it two images and it returns one composite with a new head, run entirely on MojieAI's server. No sampler, no mask, no ControlNet. Two images in, one image out.

How it works

Every node in the comfyui-MJAPI-party pack is an API wrapper, and this one is as thin as they come. It base64-encodes your source_head and replac_head, POSTs them to the pack's single gateway endpoint with the model id change_head, and waits. The server does the face detection, alignment, blending and lighting matching, then hands back an image URL that the node downloads and converts back into a normal IMAGE tensor. If anything fails, the node doesn't crash - it bakes an error image (with the API's message printed as text) into the output, which is a pattern worth knowing across the whole pack.

The inputs that matter

  • source_head (IMAGE) - your starting image.
  • replac_head (IMAGE) - the head that goes onto it. The exact reading of "source" vs "replac" isn't documented in the pack, so if the output looks like the wrong face won, just swap the two wires - it's a two-second experiment and it usually resolves the confusion.
  • seed (INT, default 0) - reproducibility. The node adds a small offset to whatever you type before sending it, so don't expect seed 1 and seed 2 to be one apart; just treat it as "same seed = same-ish result."

The single output, output, is a plain IMAGE you can wire into a save/preview node or into anything downstream.

Installing it

This ships inside the comfyui-MJAPI-party pack. In ComfyUI Manager, search mojieapi_party (or the full repo name) and install, then restart - or:

cd ComfyUI/custom_nodes
git clone https://github.com/MoJIeAIGC/comfyui-MJAPI-party.git

Then restart ComfyUI. There are no model downloads; requirements are just numpy, torch, requests, pillow, aiohttp and opencv-python. The non-negotiable step: register at mojieaigc.com, get an API key, and put it in config.ini in the pack root:

[API]
KEY = your_api_key
BASE_URL = https://www.mojieaigc.com/v1/completions

Leave BASE_URL alone, fill in KEY, restart. No key means error images on every call.

Common issues

  • You see a text-laden error image. Read it - the pack prints the API's status message into the picture. The usual culprits are a missing/invalid key, an empty account balance, or an oversized input.
  • The head looks pasted, not blended. This is an API result, not a local edit, so there's no denoise strength to fiddle with. What you can control is input quality - a clean, well-lit donor head and a matching-angle source head get you dramatically better blends. Garbage in, garbage out, same as any model.
  • The whole approach assumes the server's taste. This is the price of the "no local VRAM" trade this pack makes: identity and blending consistency live on MojieAI's side. For workflows where you need pixel-level control over the seam, the local route - face LoRAs, IP-Adapter, mask-plus-inpaint hybrids, the whole character-consistency stack - still wins. This node is for when you want the result in one call and can accept the metered cost.
Category🎨MJapiparty/Product&tool

Inputs (3)

NameTypeDefaultDescription
source_headIMAGE
replac_headIMAGE
seedINT0

Outputs (1)

NameTypeDescription
outputIMAGE