Nodes/NanoBanana FaceSwap/Nano Banana - Face Swap (Whole Image)
ComfyUI Node

Nano Banana - Face Swap (Whole Image)

Fast, simple, and mostly gets out of the way

By IxMxAMAR·Created 4 months ago·Updated about a month ago· 3
Nano Banana - Face Swap (Whole Image)
  • target_image
  • identity_1
  • identity_2
  • identity_3
  • identity_4
  • identity_5
  • identity_6
  • network
  • image
  • status
  • mask
  • debug_sheet
api_key
modelgemini-3.1-flash-image-preview
scopeface
grid_modeseparate_refs
custom_hint
safety_thresholdBLOCK_NONE
seed0
batch_axistarget
image_size2K
dry_runfalse
timeout_ms180000
ref_cap_px1024
auto_relax_on_refusedfalse

NanoBananaWholeImageSwap is the flagship of this pack and the right place to start: it sends the full target image plus up to six identity references to Google's Nano Banana, asks it to redraw the face, and hands you the result. No local model, no face-detector cascade, no crop math - just the API call and whatever the model decides. That simplicity is the appeal, and also the ceiling.

"Whole image" is the honest description. Gemini sees the entire frame and rewrites the whole thing to satisfy the edit, then the pack composites its mask back so the pixels that should have stayed identical mostly do. The README calls this pathway the "Face Detailer mode" for same-character refinement - you've already got a face you roughly like, and you want it cleaned up or nudged toward a reference - and that's exactly the sweet spot.

How it works

The request construction is where the pack earns its keep. The prompt templates deliberately avoid vocabulary that raises Gemini's safety-classifier sensitivity - no "swap", no "replace face", no "deepfake". Instead it says "edit," "redraw," "match identity." That's not hand-waving; those words measurably change refusal rates on this model, and the whole pack is engineered around that fact.

On success you get the edited image plus a per-pixel diff mask of the changed region - the pack computes what actually moved, so you can inspect or reuse the edit boundary. On refusal you get a red-tinted placeholder and a status string explaining which category fired.

Inputs that matter

  • api_key / model - Gemini key (or GEMINI_API_KEY in the environment) and the model. gemini-3.1-flash-image-preview (Nano Banana 2) is the default; gemini-3-pro-image-preview is the slower, higher-quality Pro; gemini-2.5-flash-image is the older Nano Banana 1.
  • target_image + identity_1..identity_6 - the frame to edit and the reference faces. This is the whole identity story: one ref works, more refs triangulate. grid_mode flips between sending them separate (separate_refs) and composing an auto sheet (auto_sheet) - reach for the sheet when you have 4+ angles.
  • scope - the pack's semantics: face replaces eyes/nose/mouth/jawline/skin tone but preserves hair, hairline, and ears; head replaces the whole head; head+styling throws in jewelry and makeup.
  • safety_threshold (BLOCK_NONE default) - how strict Gemini's filter should be. Note the pack's caveat: some BLOCK_NONE refusals actually relax if you drop auto_relax_on_refused on and let the model use its own defaults.
  • image_size (2K default) - 1K/2K/4K output. 4K is slower and pricier.
  • seed, batch_axis - seed for determinism; batch_axis iterates frames (target) or identities (identity) as separate API calls.
  • The v0.2 quality-of-life set: dry_run (free prompt preview), timeout_ms, ref_cap_px (downscale refs to 1024 - saves bandwidth and actually improves identity transfer, because 4K skin-pore detail confuses the model), auto_relax_on_refused, and network for a proxy route node.

Outputs

The standard four: image (result, or red-tinted on refusal), status (OK/REFUSED:<category>/ERROR:<reason>), mask (per-pixel diff mask of the changed region), and debug_sheet - the identity sheet you used, or a side-by-side input/output comparison.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana-FaceSwap
cd ComfyUI-NanoBanana-FaceSwap
pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager under "NanoBanana FaceSwap." You need a Gemini API key. The good news about being API-based: no multi-gigabyte checkpoint, no VRAM ceiling - the bad news: every queue is a paid API call (~$0.039 for a single Flash image, more for Pro/4K), and IS_CHANGED returns NaN so nodes always re-run.

Troubleshooting

  • REFUSED:<category> - the classifier fired. First try auto_relax_on_refused; then step down the pack's ladder: Crop & Composite for scene-content refusals, Mask Inpaint or the Unbiased path for identity refusals.
  • Hair/ears changed when you wanted only the face - you're on scope=head. Drop to face.
  • Result too smoothed / plastic - Flash's look at high strength. Bump the model to Pro, or accept that and fix details downstream.
  • Everything changes, nothing matches - classic ref problem. Add more angles, use a composed sheet, and set ref_cap_px - surprisingly, less detail per ref often locks identity better.
  • Face near the image edge comes back misaligned - that's the whole-image path showing its limits; the Crop & Composite node was built for exactly this case.
CategoryNanoBanana FaceSwap

Inputs (21)

NameTypeDefaultDescription
api_keySTRING
modelCOMBOgemini-3.1-flash-image-preview3 options: gemini-3.1-flash-image-preview, gemini-3-pro-image-preview, gemini-2.5-flash-image
target_imageIMAGE
identity_1IMAGE
scopeCOMBOface3 options: face, head, head+styling
grid_modeCOMBOseparate_refs2 options: separate_refs, auto_sheet
custom_hintSTRING
safety_thresholdCOMBOBLOCK_NONE4 options: BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE
seedINT00–2147483647
batch_axisCOMBOtarget2 options: target, identity
image_sizeCOMBO2K3 options: 1K, 2K, 4K
identity_2optIMAGE
identity_3optIMAGE
identity_4optIMAGE
identity_5optIMAGE
identity_6optIMAGE
dry_runoptBOOLEANfalseSkip the API call and return a structured preview of the prompt + parts that would have been sent. Burns no quota; useful for debugging custom_hint and prompt builders.
timeout_msoptINT1800005000–600000Per-call API timeout in milliseconds. Lower (e.g. 30000) lets you fail fast on stuck calls; higher tolerates slow Pro-tier renders.
ref_cap_pxoptINT10240–4096Downscale identity reference images so their longest edge is at most this many pixels before send. 0 = disabled. 1024 saves bandwidth and empirically improves identity transfer (4K pore detail confuses the model).
auto_relax_on_refusedoptBOOLEANfalseIf the model refuses, retry once with no safety_settings (model defaults). Some BLOCK_NONE refusals relax under defaults.
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this swap's API call through that proxy (e.g. US egress).

Outputs (4)

NameTypeDescription
imageIMAGE
statusSTRING
maskMASK
debug_sheetIMAGE