ADetailer Inpainting#
ADetailer is a Stable Diffusion WebUI extension that auto-detects regions in a generated image (faces, hands, etc.) using Ultralytics or MediaPipe models, then re-inpaints each detected region using a standard StableDiffusionProcessingImg2Img pipeline. Inpainting parameters are bundled in the ADetailerArgs Pydantic model (adetailer/args.py) and passed to the per-region processing loop in _postprocess_image_inner().
The core inpainting setup happens in get_i2i_p(), which creates the StableDiffusionProcessingImg2Img object and maps ADetailerArgs fields directly to its parameters.
Key Inpainting Parameters#
Denoising Strength (ad_denoising_strength)
Controls regeneration intensity β how much the inpainted region deviates from the original. Default is 0.4 . Passed as denoising_strength in get_i2i_p(). A value of 1.0 fully regenerates; lower values preserve more of the original content.
Dynamic Denoising Strength (ad_dynamic_denoise_power, global setting)
An optional power-scaling modifier (range β10 to 10, default 0 = disabled) that automatically reduces denoising strength for larger detected regions . The modifier is applied in get_dynamic_denoise_strength(), which calls dynamic_denoise_strength() from adetailer/opts.py:
denoise_modifier = (1.0 - normalized_area) ** denoise_power
return denoise_strength * denoise_modifier
This means smaller detected areas (e.g., a tiny face in a crowd) receive proportionally more denoising, while large areas are adjusted less aggressively. Values of 2β4 are documented as recommended .
Mask Blur (ad_mask_blur)
Blends the boundary between the inpainted region and the surrounding image. Default is 4 . Passed directly as mask_blur to the underlying img2img processor β higher values soften the transition edge.
Inpaint Only Masked + Padding (ad_inpaint_only_masked, ad_inpaint_only_masked_padding)
When ad_inpaint_only_masked=True (default), diffusion runs only on the cropped mask region instead of the full image, greatly improving performance . The padding adds pixels around the mask bounding box to provide context; default is 32 px. Both map to inpaint_full_res and inpaint_full_res_padding in the img2img object.
Restore Face (ad_restore_face)
Boolean, default False . When True, applies the WebUI's built-in face restoration post-processor after each inpaint pass via restore_faces=True on the img2img object. This is a secondary fix layered on top of ADetailer's own detection-based inpainting.
Mask Shaping Parameters#
These parameters preprocess the detection masks before inpainting:
| Parameter | Default | Description |
|---|---|---|
ad_dilate_erode | 4 | Positive = dilate (expand) mask, negative = erode (shrink) |
ad_mask_blur | 4 | Gaussian blur applied to mask edges before inpainting |
ad_x_offset / ad_y_offset | 0 | Translate mask position in pixels |
ad_mask_merge_invert | "None" | Merge/invert multiple masks: None, Merge, or Merge and Invert |
Mask preprocessing runs in pred_preprocessing() via mask_preprocess() from adetailer/mask.py.
Inpaint Resolution Controls#
Fixed width/height (ad_use_inpaint_width_height, ad_inpaint_width, ad_inpaint_height)
When enabled, inpaints at a fixed resolution (default 512Γ512) regardless of the original image size .
Bounding Box Size Matching (ad_match_inpaint_bbox_size, global setting)
A global option (Off / Strict / Free) that tries to match the inpainting crop resolution to the detected region's aspect ratio :
- Strict β snaps to the nearest official SDXL-trained resolution
- Free β scales to any aspect ratio, rounded to the nearest 8 px
Applied in get_optimal_crop_image_size() and fix_p2().
Color Preservation#
ADetailer does not implement its own explicit color correction. Color consistency between the inpainted patch and the surrounding image is entirely delegated to the base Stable Diffusion inpainting fill mode (inpainting_fill=1, i.e., "original" fill) . Users needing additional color correction typically apply ControlNet tile models (e.g., tile_colorfix) as an ad_controlnet_model.
Source References#
| File | Purpose |
|---|---|
adetailer/args.py | All parameter definitions and defaults (ADetailerArgs) |
adetailer/opts.py | dynamic_denoise_strength() and optimal_crop_size helpers |
scripts/!adetailer.py | Main script: get_i2i_p(), _postprocess_image_inner(), fix_p2(), global settings registration |