How Inpainting Works
- Define area: Create a mask marking the region to regenerate
- Encode: Convert image and mask to latent space
- Denoise: Only regenerate the masked area
- Decode: Blend seamlessly with unmasked regions
- Standard models with VAEEncodeForInpaint
- Dedicated inpaint models with InpaintModelConditioning
Standard Model Inpainting
Works with any Stable Diffusion model.- Paint white on areas to regenerate
- Black = preserve
- White = repaint
- pixels: from LoadImage
- vae: from CheckpointLoaderSimple
- mask: from LoadImage mask output (or LoadImageMask)
- Expands mask slightly for seamless blending
- Higher values = softer edges
- Range: 0-64 pixels
Positive: "grass lawn, natural lighting, photorealistic, seamless"
Negative: "object, person, artifacts, visible seams, inconsistent lighting"
- latent_image: from VAEEncodeForInpaint
- denoise: 1.0 (full regeneration of masked area)
- steps: 25-40 (higher for better blending)
- cfg: 7-8
Workflow JSON: Standard Inpainting
Inpaint Model Workflow
Dedicated inpaint models (like SD 1.5 inpaint) produce better results for complex edits.- positive: from positive CLIPTextEncode
- negative: from negative CLIPTextEncode
- vae: from checkpoint
- pixels: from LoadImage
- mask: from LoadImage mask output
- Limits sampling to masked area
- Improves quality and speed
Workflow JSON: Inpaint Model
Common Use Cases
Object Removal
Goal: Remove unwanted elements- Mask the object to remove
- Prompt what should be there instead
- Use high grow_mask_by (8-16) for better blending
Adding Elements
Goal: Insert new objects or details- Mask where new element should appear
- Detailed prompt describing the addition
- Include lighting/style context
Face/Detail Fixing
Goal: Improve specific details- Mask problem area tightly
- Describe desired result
- Low grow_mask_by (2-4)
Background Extension (Outpainting)
Goal: Expand image borders- Use ImagePadForOutpaint node to extend canvas
- Mask the new area
- Prompt continuation of the scene
Mask Creation Tips
Manual Masking
- Use image editor (Photoshop, GIMP, etc.)
- White = regenerate, Black = keep
- Soft edges with blur for better blending
- Save with alpha channel
Mask from Alpha Channel
Use LoadImageMask:Feathering
grow_mask_by creates smooth transitions:- Small objects: 4-8
- Medium areas: 8-16
- Large regions: 16-32
- Full image blend: 40+
Advanced Techniques
Multi-Region Inpainting
- Create mask with multiple separate areas
- Prompt describes all areas together
- Higher steps (40-60) for complexity
Iterative Refinement
- First pass: Rough inpaint, denoise 1.0
- Save result
- Second pass: Load result, smaller mask, denoise 0.6-0.8
- Refine specific details
Compositional Inpainting
Use ConditioningSetMask for regional prompts:Parameter Guide
grow_mask_by
- 0: Hard edges, visible seams
- 2-4: Tight blending, detail work
- 6-8: Standard blending (default)
- 12-16: Soft transitions, large areas
- 32+: Very gradual blend, outpainting
Steps
- 20-30: Quick edits, simple fills
- 30-40: Standard quality
- 40-60: Complex inpainting, multiple objects
- 60+: Challenging blends, high detail
CFG Scale
- 6-7: Natural blending, less artifacts
- 7-8: Balanced (recommended)
- 8-10: Strong prompt adherence, adding specific objects
- 10+: Risk of oversaturation at mask edges
Troubleshooting
Visible seams
- Increase grow_mask_by (try 12-20)
- Lower CFG scale (try 6-7)
- Increase steps (35-50)
- Use softer mask edges
Generated area doesn’t match
- Describe surrounding context in prompt
- Include lighting/style references
- Try dedicated inpaint model
- Increase CFG for stronger adherence
Blurry results
- Increase steps (40+)
- Use better sampler (dpm++ sde karras)
- Check VAE quality
- Try dedicated inpaint model
Changes bleed outside mask
- Reduce grow_mask_by
- Use hard-edged mask
- Enable noise_mask (inpaint models)
- Lower denoise slightly (0.95)
Best Practices
- Match the style: Prompt should describe existing image style
- Contextual prompts: Reference surrounding elements
- Start simple: Test with small masks first
- Iterate: Run multiple generations, pick best
- Feather appropriately: Match grow_mask_by to edit size
- Consider dedicated models: Better for complex edits
- Higher steps: Inpainting benefits from extra refinement
Next Steps
- Combine with ControlNet for precise inpainting
- Explore regional prompting with ConditioningSetMask
- Try different inpaint-specific models
- Experiment with outpainting for image extension