π Gemini Pro Batch Refine
Fix the tiny details without touching the rest of the photo
- images
- image_2
- image_3
- image_4
- image_5
- image_6
- image_7
- image_8
- image_9
- image_10
- image_11
- image_12
- refined_images
- summary
- metadata
The usual failure mode of a good product render isn't the whole image - it's one logo that came out as mush, a label with a hallucinated letter, stitching that reads as static. Gemini Pro Batch Refine is the node for exactly that job: it takes a batch of images and re-renders each one with the details corrected against reference shots, while leaving everything else pixel-identical. It's the "refine" stage of a detect β crop β refine β stitch pipeline, and it's the most niche thing in this pack - built for e-commerce garment work, useful anywhere a close-up photo needs forensic detail repair.
It's one of the API nodes, so it needs a Google API key and it costs money per call. This is Nano Banana Pro (Gemini 3 Pro Image) under the hood, and you feel it in the pricing and in the output quality - the default system prompt is a tightly-worded "identity lock" contract that orders the model to keep the crop, framing, lighting, and fabric texture exactly as-is and change only the specific wrong detail.
How it works
The node is list-aware (INPUT_IS_LIST), so every image you feed in is refined separately against the same shared reference shots. Each iteration becomes its own API call: {image_1} is the per-iteration base crop, and {image_2} through {image_12} are optional reference images - the close-ups of the correct logo, label, or hardware that the model is told to copy "like a forensic document."
Two behaviors matter before you run it. The seed is per-batch: 0 means random each iteration, but any non-zero seed produces seed + i for the i-th item, so a fixed seed gives you reproducible refinements across the whole batch. And stop_on_error defaults to off - a failed iteration inserts a tiny (1,1,1,3) placeholder and keeps going, which sounds weird but exists to preserve index alignment with the alphas_list from Gemini Mask Crop downstream. If you'd rather the whole run abort on the first failure, flip it on.
Inputs that matter
- images - wire this from Gemini Mask Crop's
images_list(native-size list) or any IMAGE/batch source. Each entry is refined separately. - system_prompt - the default is the garment identity-lock prompt. It's editable and replaces fine - the
{image_1}/{image_2}placeholders are the contract. - image_2 β¦ image_12 - the reference shots. They're optional but pointless to skip; the whole node exists to copy details from them.
- aspect_ratio - leave at
customso the model keeps the base image's framing, which is what you want for refinement. - image_size - 1K / 2K / 4K resolution tier. 2K is the sane default; 4K is where the bill climbs.
Outputs are refined_images (a list, one per input), a summary string, and a metadata dict with per-iteration latency and success info. Feed the refined list straight into Gemini Mask Stitch to put the corrections back on the original.
Install and the key
Install via ComfyUI Manager (search "ComfyUI_Gemini") or clone into custom_nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/aarnoatchi/ComfyUI_Gemini
pip install -r ComfyUI_Gemini/requirements.txt
The requirements pull in google-genai - not google-generativeai, which is the classic gotcha (the pack even auto-uninstalls the wrong one at startup). For the key, put GOOGLE_API_KEY=... in the .env file the pack creates in its own folder and leave the node's key field empty, so your shared workflow JSON never embeds the secret.
Where people get burned
Cost sneaks up fast: a batch of ten crops with several reference shots is ten separate paid generations. Watch the *-image-preview model names - Google retires preview variants, so if one errors out, move to the GA name (gemini-3-pro-image). Safety filters can silently block, and if you get "API key is missing" check that the .env value isn't still the placeholder. This pack is a small, single-author project - 14 threads by name in the community corpus, nothing by author name - so don't expect a support army; the console output is actually detailed and worth reading when something fails.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Per-iteration {image_1} base. Wire from Mask Crop.images_list (native-size list) or any IMAGE/IMAGE-batch source. Each entry is refined separately against the same reference shots. | |
| model | COMBO | gemini-3-pro-image | 4 options: gemini-3-pro-image-preview, gemini-3-pro-image, gemini-3.1-flash-image-preview, gemini-3.1-flash-image |
| system_prompt | STRING | Refine the details in a cropped garment image using close-up reference shots, while keeping the entire image absolutely identical to the input. INPUTS {image_1}: The cropped area of the garment image that needs refinement β this is the base image. The output must match this exactly in every way except the specific details being corrected {image_2}, {image_3}, {image_4}, {image_5}: Detail reference shots β the MASTER REFERENCE for the correct logos, labels, hardware, stitching, trims, text, or any other detail that needs to be refined TASK Reproduce {image_1} pixel-perfectly, with one change only: replace any incorrect, blurry, hallucinated, or imprecise detail with the accurate version sourced from the reference shots. OUTPUT RULES Identity Lock β CRITICAL: - The output must be the exact same image as {image_1} β same crop, same framing, same angle, same perspective, same lighting, same background, same fabric texture, same folds, same wrinkles, same shadows - Do NOT reframe, zoom, rotate, rescale, or recompose the image in any way - Do NOT change the image format from flat lay to 3D, from 3D to flat lay, or into any other presentation style - Do NOT add volume, remove volume, alter the garment shape, or change any structural element - Do NOT alter lighting, color temperature, grain, sharpness, or depth of field - The only permitted change is the correction of specific detail content β everything else is frozen Detail Refinement from the reference shots β CRITICAL: - Study each detail reference at the highest possible fidelity before generating - Every character, stroke, color, spacing, proportion, and finish in the reference must be reproduced in the refined output - Logos: exact shape, color, typography, and layout β no simplification, no approximation, no invention - Text: every letter must match the reference exactly β correct font weight, kerning, capitalization, and color - Labels and tags: exact label design, stitching style, and placement as shown in the reference - Hardware: exact shape, finish, and material appearance - Stitching and trims: exact stitch density, color, and construction - Treat each reference image as a forensic document β copy it, do not interpret it Integration β CRITICAL: - The refined detail must sit naturally within the existing image β matching the perspective, scale, lighting, and surface texture of the surrounding area in {image_1} - The boundary between the refined area and the surrounding image must be seamless β no visible edge, no color shift, no sharpness difference, no halo - The corrected detail must look as if it was always correct in {image_1} β not patched, not composited, not replaced NEGATIVE RULES - Do NOT change the image style, format, or presentation in any way - Do NOT convert flat lay to 3D or 3D to flat lay - Do NOT alter garment shape, volume, or structure - Do NOT change lighting, shadows, grain, or color temperature - Do NOT reframe, crop differently, zoom in or out, or rotate - Do NOT invent details not present in the reference shots - Do NOT alter any area of the image outside the detail being corrected - Do NOT smooth, sharpen, or retouch the image beyond what is necessary for the detail correction PRIORITY ORDER 1. Output is identical to {image_1} in every way β same crop, same style, same lighting, same structure 2. Correct detail content reproduced with forensic accuracy from the reference shots 3. Seamless integration β corrected detail matches surrounding perspective, scale, and lighting 4. Zero visible boundary between corrected area and rest of image 5. No changes outside the specific detail being corrected OUTPUT One image identical to {image_1} in every way β same crop, same framing, same style, same lighting β with only the incorrect detail replaced by the accurate version sourced from the reference shots, integrated seamlessly so the correction is invisible and the result reads as the original image always being correct. The logic is simple: {image_1} is the contract for everything β format, style, lighting, structure. The reference shots are the contract for detail content only. Nothing else changes. | Prompt used for every iteration. {image_1} is the per-iteration base; {image_2}..{image_12} reference the optional reference inputs. |
| aspect_ratio | COMBO | custom | 'custom' = let the model decide based on the base image (recommended for refinement). |
| image_size | COMBO | 2K | 3 options: 1K, 2K, 4K |
| seed | INT | 00β2147483647 | 0 = random per iteration. Non-zero seeds yield seed+i for the i-th item, so the same seed gives reproducible refinements across the whole batch. |
| temperature | FLOAT | 1.000β1 | β |
| image_2opt | IMAGE | β | |
| image_3opt | IMAGE | β | |
| image_4opt | IMAGE | β | |
| image_5opt | IMAGE | β | |
| image_6opt | IMAGE | β | |
| image_7opt | IMAGE | β | |
| image_8opt | IMAGE | β | |
| image_9opt | IMAGE | β | |
| image_10opt | IMAGE | β | |
| image_11opt | IMAGE | β | |
| image_12opt | IMAGE | β | |
| additional_promptopt | STRING | β | |
| project_nameopt | STRING | β | |
| stop_on_erroropt | BOOLEAN | false | If True, abort the batch on the first failed iteration. If False (default), insert a (1,1,1,3) placeholder and continue, preserving index alignment with downstream alphas_list. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| refined_images | IMAGE | β |
| summary | STRING | β |
| metadata | DICT | β |