BrushNet
RepositoryFree[ECCV 2024] The official implementation of paper "BrushNet: A Plug-and-Play Image Inpainting Model with Decomposed Dual-Branch Diffusion"
Capabilities12 decomposed
decomposed dual-branch diffusion inpainting with masked feature separation
Medium confidenceImplements a specialized dual-branch architecture that separates masked image features from noisy latent features during the diffusion process, reducing the model's learning load and enabling precise inpainting. The architecture processes segmentation or random masks through dedicated branches that converge at multiple resolution levels, allowing the base diffusion model to focus on content generation within masked regions while preserving unmasked areas. This decomposition is achieved through custom UNet modifications in the diffusers library that inject BrushNet control at intermediate layers without requiring full model retraining.
Uses decomposed dual-branch architecture with dense per-pixel control injected at multiple UNet resolution levels, enabling plug-and-play integration without modifying base model weights. Unlike naive masking approaches, separates masked feature processing from latent noise processing, reducing learning burden and improving boundary quality.
Achieves higher inpainting quality than simple mask-based approaches (e.g., Inpaint-LoRA) while maintaining compatibility with any pre-trained diffusion model, and requires significantly less training data than full model fine-tuning approaches.
text-guided inpainting pipeline with multi-variant model support
Medium confidenceProvides unified inference pipelines (StableDiffusionBrushNetPipeline and StableDiffusionXLBrushNetPipeline) that orchestrate the complete inpainting workflow: text encoding via CLIP/OpenCLIP, mask preprocessing, latent encoding of the original image, iterative diffusion with BrushNet control injection, and final decoding. The pipeline abstracts away the complexity of managing multiple model components (text encoder, VAE, UNet, scheduler) and provides a simple API while supporting both SD 1.5 and SDXL base models with separate segmentation and random mask variants.
Provides unified pipeline abstraction that handles model variant selection (SD 1.5 vs SDXL, segmentation vs random mask) and component orchestration transparently, with built-in support for both guidance scale and negative prompts for fine-grained control over generation quality.
Simpler API than raw diffusers pipeline usage while maintaining full control over inference parameters; supports both SD 1.5 and SDXL without code changes, unlike single-model implementations.
model weight quantization and optimization for deployment
Medium confidenceProvides tools for reducing model size and inference latency through quantization (INT8, FP16) and optimization techniques. The system supports post-training quantization of BrushNet weights, mixed-precision inference (FP16 for forward pass, FP32 for critical operations), and optional pruning of less important weights. Quantized models achieve 2-4x speedup with minimal quality loss, enabling deployment on resource-constrained devices (edge GPUs, mobile) or higher throughput on servers.
Provides integrated quantization pipeline with quality validation and performance benchmarking, supporting multiple quantization strategies (INT8, FP16, dynamic) with automatic calibration and fallback mechanisms for numerical stability.
Simpler than manual quantization using TensorRT or ONNX while maintaining quality validation; supports multiple quantization types with automatic selection based on target device, unlike single-strategy approaches.
integration with huggingface diffusers ecosystem
Medium confidenceProvides seamless integration with the HuggingFace diffusers library, enabling BrushNet to work with any diffusers-compatible scheduler, pipeline, and model. The integration includes custom BrushNet model classes (BrushNetModel) that inherit from diffusers base classes, custom pipeline classes (StableDiffusionBrushNetPipeline) that follow diffusers conventions, and compatibility with diffusers utilities (safety checker, feature extractor). This enables users to leverage the entire diffusers ecosystem (LoRA, ControlNet, other extensions) alongside BrushNet.
Implements BrushNet as native diffusers components (BrushNetModel, custom pipelines) following diffusers conventions, enabling seamless composition with other diffusers extensions and schedulers without wrapper layers or compatibility shims.
Tighter integration than wrapper-based approaches; BrushNet components inherit from diffusers base classes, enabling direct use of diffusers utilities and compatibility with the broader ecosystem, unlike standalone implementations.
mask-aware latent encoding and feature extraction
Medium confidencePreprocesses input images and masks into latent space representations that preserve spatial information about masked vs unmasked regions. The system encodes the original image through the VAE encoder, then applies mask-aware feature extraction that separates masked image features from the noisy latent representation. This preprocessing step is critical for the dual-branch architecture, as it ensures the BrushNet model receives properly formatted input that distinguishes between regions to inpaint and regions to preserve, using spatial masking operations at the latent level (typically 8x downsampled from image space).
Implements mask-aware latent extraction that preserves spatial masking information through the VAE encoding process, using dual-branch feature separation at latent level rather than image level, enabling efficient per-pixel control without full image-resolution processing.
More efficient than image-space masking because it operates on 8x downsampled latents, reducing memory and compute requirements while maintaining spatial precision through dedicated mask channels in the latent representation.
multi-resolution dense per-pixel control injection
Medium confidenceInjects BrushNet control signals at multiple UNet resolution levels (typically 4 scales: 64x64, 32x32, 16x16, 8x8) to provide fine-grained guidance over the diffusion process. The control mechanism works by modifying the UNet's cross-attention and self-attention layers with BrushNet-specific conditioning that incorporates mask information and masked image features at each resolution. This multi-scale injection ensures that both coarse structure (from low-resolution features) and fine details (from high-resolution features) are properly controlled, enabling precise inpainting without affecting unmasked regions.
Implements dense per-pixel control through multi-resolution feature injection at 4 UNet scales simultaneously, using decomposed masked image features rather than simple concatenation, enabling structural guidance without sacrificing fine detail quality or affecting unmasked regions.
Provides finer spatial control than single-scale guidance (e.g., ControlNet) while maintaining compatibility with pre-trained models; multi-scale approach ensures both coarse structure and fine details are properly guided, unlike naive mask-based approaches that only work at one resolution.
segmentation and random mask variant support
Medium confidenceProvides separate model variants optimized for two distinct mask types: segmentation masks (clean, object-shaped boundaries) and random masks (arbitrary, potentially irregular shapes). Each variant is trained with different mask distributions and augmentation strategies to handle the specific characteristics of its target mask type. The system automatically selects the appropriate variant based on mask properties or allows explicit selection, enabling optimal inpainting quality for different use cases without requiring users to understand the underlying mask type differences.
Provides separate trained variants for segmentation vs random masks rather than single unified model, with each variant optimized for its mask type's specific characteristics through targeted training data augmentation and loss weighting strategies.
Achieves better quality than single-model approaches by training separately for each mask type's distribution; segmentation variant produces cleaner object boundaries while random variant handles freeform masks without over-smoothing, unlike generic inpainting models.
training pipeline with dataset preparation and augmentation
Medium confidenceProvides end-to-end training infrastructure for fine-tuning BrushNet on custom datasets, including dataset loading, mask generation/augmentation, and training loop management. The training system supports both SD 1.5 and SDXL base models with separate training scripts, implements mask augmentation strategies (random mask generation, boundary noise, dilation/erosion), and uses mixed-precision training with gradient accumulation for memory efficiency. Training can be performed on standard datasets (Places, CelebA-HQ) or custom image collections, with support for distributed training across multiple GPUs.
Implements mask-type-specific training pipelines with separate augmentation strategies for segmentation vs random masks, using mixed-precision training and gradient accumulation to fit on consumer GPUs while maintaining convergence quality comparable to full-precision training.
Provides complete training infrastructure including dataset preparation and augmentation, unlike inference-only implementations; supports both SD 1.5 and SDXL with separate optimized training scripts, enabling domain-specific model adaptation without external training frameworks.
evaluation metrics computation (lpips, fid, ssim)
Medium confidenceComputes standard image quality metrics for evaluating inpainting results: LPIPS (learned perceptual image patch similarity) for perceptual quality, FID (Fréchet Inception Distance) for distribution matching, and SSIM (structural similarity) for pixel-level fidelity. The evaluation system loads pre-trained feature extractors (InceptionV3 for FID, AlexNet for LPIPS) and compares generated inpainted images against ground truth or reference images. Results are aggregated across test sets and reported with statistical summaries (mean, std, percentiles).
Integrates three complementary metrics (perceptual LPIPS, distribution FID, and structural SSIM) with pre-trained feature extractors, providing both aggregate statistics and per-image scores for detailed analysis of inpainting quality across different aspects.
Provides comprehensive evaluation using multiple metrics rather than single-metric approaches; includes both perceptual (LPIPS) and distribution-level (FID) metrics, enabling nuanced quality assessment compared to pixel-only metrics like SSIM.
gradio web interface for interactive inpainting
Medium confidenceProvides a browser-based interactive interface for real-time inpainting using Gradio, enabling users to upload images, draw masks, enter text prompts, and adjust inference parameters (guidance scale, steps) without coding. The interface handles image upload, mask drawing with canvas tools, prompt input, and displays results with latency information. The Gradio app wraps the inference pipeline and can be deployed locally or on cloud platforms (HuggingFace Spaces, Gradio Cloud) for easy sharing and collaboration.
Provides lightweight Gradio-based web interface with integrated mask drawing canvas, parameter controls, and real-time inference feedback, enabling non-technical users to interact with BrushNet without API knowledge or local setup.
Simpler to deploy than custom web frameworks (Flask, FastAPI) while maintaining full inference control; Gradio's automatic API generation enables easy integration with other tools, and built-in sharing features (HuggingFace Spaces) require no infrastructure setup.
instruction-guided editing with text-based spatial control
Medium confidenceExtends basic text-guided inpainting with instruction-based editing that interprets natural language instructions to automatically generate masks and guide inpainting. The system parses instructions like 'remove the person on the left' or 'replace the sky with clouds' to identify regions of interest and apply appropriate inpainting. This capability combines text understanding with spatial reasoning, potentially using auxiliary models (object detection, segmentation) to convert instructions into masks before applying BrushNet inpainting.
Combines text-guided inpainting with instruction parsing and spatial reasoning to enable high-level editing commands without manual mask drawing, using auxiliary models for object detection/segmentation to convert natural language into spatial masks.
More user-friendly than manual mask drawing while maintaining precise control through text instructions; leverages BrushNet's text-guided capabilities with automated mask generation, unlike simple inpainting tools that require manual mask creation.
batch processing with multi-image inpainting
Medium confidenceEnables efficient processing of multiple images with different masks and prompts in a single batch, optimizing GPU utilization and reducing per-image overhead. The batch processor handles variable image sizes through padding/resizing, manages memory efficiently with dynamic batching, and provides progress tracking and error handling for robust production use. Results are returned with metadata (processing time, success/failure status) for each image.
Implements dynamic batching with variable image size handling through padding/resizing, providing efficient GPU utilization for multi-image workloads while maintaining per-image metadata and error tracking for production robustness.
More efficient than sequential single-image processing by batching multiple images on GPU; handles variable sizes automatically unlike naive batching approaches, and includes comprehensive error handling and progress tracking for production use.
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with BrushNet, ranked by overlap. Discovered automatically through the match graph.
IOPaint
Image inpainting tool powered by SOTA AI Model. Remove any unwanted object, defect, people from your pictures or erase and replace(powered by stable diffusion) any thing on your pictures.
On Distillation of Guided Diffusion Models
* ⭐ 10/2022: [LAION-5B: An open large-scale dataset for training next generation image-text models (LAION-5B)](https://arxiv.org/abs/2210.08402)
Qwen-Image-Edit-2511-LoRAs-Fast
Qwen-Image-Edit-2511-LoRAs-Fast — AI demo on HuggingFace
Imagen
Imagen by Google is a text-to-image diffusion model with an unprecedented degree of photorealism and a deep level of language...
diffusionbee-stable-diffusion-ui
Diffusion Bee is the easiest way to run Stable Diffusion locally on your M1 Mac. Comes with a one-click installer. No dependencies or technical knowledge needed.
Denoising Diffusion Probabilistic Models (DDPM)
* 🏆 2020: [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale (ViT)](https://arxiv.org/abs/2010.11929)
Best For
- ✓Computer vision researchers implementing plug-and-play diffusion extensions
- ✓ML engineers building image editing applications on top of Stable Diffusion
- ✓Teams requiring production-grade inpainting without full model retraining
- ✓Application developers building image editing UIs or APIs
- ✓Data scientists prototyping inpainting workflows
- ✓Teams deploying inpainting as a microservice
- ✓ML engineers optimizing models for production deployment
- ✓Teams building edge AI applications with resource constraints
Known Limitations
- ⚠Requires pre-trained base diffusion model (SD 1.5 or SDXL) — cannot function standalone
- ⚠Inference latency depends on base model's diffusion steps (typically 50-100 steps for quality results)
- ⚠Memory footprint scales with image resolution; 4K+ images may require gradient checkpointing or reduced batch sizes
- ⚠Mask quality directly impacts output quality — poorly defined masks produce artifacts at boundaries
- ⚠Pipeline initialization loads all model components into memory (~7GB for SD 1.5, ~13GB for SDXL) — requires GPU with sufficient VRAM
- ⚠Sequential processing of batches; no built-in distributed inference across multiple GPUs
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
Repository Details
Last commit: Dec 17, 2024
About
[ECCV 2024] The official implementation of paper "BrushNet: A Plug-and-Play Image Inpainting Model with Decomposed Dual-Branch Diffusion"
Categories
Alternatives to BrushNet
Are you the builder of BrushNet?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →