Hand Repair Workflow: Boosting AI Image Quality with Low GPU Memory

CN
ComfyUI.org
2025-05-13 11:46:33

1. Workflow Overview

mamg339hzm8ywclbpbi88dfd1e175ec9e43ead9e6a1394f6596cf277c7cebf0a09e3d77712090379fb2.jpg

This workflow is designed to fix deformed hands in AI-generated images with low GPU memory usage. Key features:

  • Hand Localization: Masks precisely mark defective hand areas.

  • Local Inpainting: Combines Flux models and depth learning for hand detail repair.

  • Seamless Blending: Ensures natural transitions between repaired and original areas.

Core Models:

  • Base Model: 基础算法_F.1 (UNET for general image generation).

  • Flux Model: Loaded via DualCLIPLoader (version t5xxl_fp8_e4m3fn).

  • Auxiliary: SegmentAnythingUltra V2 (auto-segment hands).


2. Key Nodes & Installation

Node

Function

Installation

InpaintResize

Resizes input image/mask to fit repair area.

Built-in.

GrowMaskWithBlur

Expands and blurs mask edges for smooth blending.

Install comfyui-impact-pack.

SegmentAnythingUltra V2

Auto-generates hand masks.

Install ComfyUI_LayerStyle_Advance; download sam_vit_l_0b3195.pth.

BasicGuider

Optimizes conditioning with Flux for hand details.

Built-in.

SamplerCustomAdvanced

Custom sampler controls noise/detail during repair.

Built-in.

Dependencies:

  • Flux model via DualCLIPLoader.

  • Place ae.sft in models/vae.


3. Workflow Structure

Group 1: Input & Preprocessing

  • Input: Original image (e.g., clipspace-mask-175661.png) and hand mask.

  • Steps:

    1. Load image/mask via LoadImage.

    2. Resize with InpaintResize (e.g., 1536x1536).

    3. Remove alpha channel via ImageRemoveAlpha.

Group 2: Hand Repair

  • Input: Preprocessed image, mask, prompt (e.g., "perfect hand").

  • Steps:

    1. Crop hand area via InpaintCrop.

    2. Optimize conditioning with BasicGuider.

    3. Generate repaired latent image via SamplerCustomAdvanced (Euler sampler).

Group 3: Blending & Output

  • Input: Repaired hand image, original, mask.

  • Steps:

    1. Blend with InpaintStitch (method: bislerp).

    2. Save result via SaveImage (e.g., flux/20240513_142301_修手.png).


4. Inputs & Outputs

Inputs:

  • Image: Include hands (resolution ≥800x800).

  • Mask: Accurately mark defective areas (black/white).

  • Prompt: Simple target description (e.g., "perfect hand").

Output:

  • Repaired PNG saved in flux/date/time_修手.png.


5. Notes

  1. VRAM Optimization:

    • Optimized for ≥6GB GPUs. Reduce InpaintResize output (e.g., 1024x1024) if needed.

  2. Mask Accuracy:

    • Manually refine masks if auto-segmentation fails.

  3. Compatibility:

    • Ensure Flux model matches base algorithm version.

  4. Debugging:

    • Adjust GrowMaskWithBlur (default: 30px expansion, 0.1 blur) for better edges.