Sketchffusion: Sketch-Guided Image Editing with Diffusion Model

Weihang Mao, Bo Han, Zihao Wang

TL;DR

This paper introduces SketchFFusion, a novel approach for sketch-guided image editing that leverages diffusion models. It addresses the challenge of scarce human sketches by proposing a sketch generation method that mimics user styles and a conditional diffusion model that effectively incorporates sketch information for precise local image editing, outperforming existing methods.

What Problem Does This Paper Address?

Sketch-guided image editing aims to allow users to precisely modify specific regions of an image by providing a sketch. However, a major hurdle is the difficulty and cost of obtaining high-quality human sketches. Existing methods often resort to using edge maps as a proxy for sketches, but these lack the rich structural and stylistic nuances of hand-drawn lines. Furthermore, current sketch-guided editing techniques can suffer from issues like image distortion, high training costs, and loss of fine details, especially when trying to maintain consistency with the rest of the image. This paper tackles these limitations by proposing a way to generate realistic sketches and a more robust editing model.

Methods

The core of SketchFFusion lies in two main components: a sketch generation framework and a conditional diffusion model for editing.

  1. Sketch Generation: To overcome the scarcity of human sketches, the authors propose a method to generate them. This involves:
  2. Extracting edge information from an image.
  3. Applying a carefully chosen threshold (e.g., 125) to binarize and invert the edges, aiming to capture main contours while mimicking the style of human drawings.
  4. A random mask generation strategy is employed to create diverse editing regions, simulating user editing habits.
  5. Conditional Diffusion Model (SketchFFusion): This model builds upon diffusion models for image editing.
  6. It utilizes a VQGAN-based autoencoder to compress image and sketch features into a lower-dimensional latent space. This helps alleviate detail loss during the editing process.
  7. The model takes the original image, a generated mask, and a sketch corresponding to the masked region as input.
  8. During the diffusion process, noise is added to the latent representation of the image.
  9. The denoising process then iteratively removes noise, guided by the conditional information from the image, sketch, and mask. This ensures that the edits are localized and consistent with the provided sketch.
  10. The model is trained by minimizing the mean squared error between the predicted noise and the actual added noise in the latent space.

Datasets

  • CelebA-HQ: Used for training and evaluation. This dataset consists of 30,003 high-resolution facial images.
  • COCO-AIGC Dataset: A newly constructed dataset for evaluating the model on diverse image categories. It's derived from the COCO dataset by using text descriptions to generate multi-style AIGC images.

Key Insights and Ideas

  • Mimicking Human Sketches: The insight that edge maps are insufficient and that a threshold-based binarization can effectively simulate the structural and stylistic properties of human sketches is crucial. This makes the system more user-friendly and the edits more natural.
  • Latent Space Diffusion for Editing: By performing diffusion in the compressed latent space provided by VQGAN, the model can efficiently incorporate sketch guidance while mitigating the loss of fine details that can occur in pixel-space editing.
  • Conditional Guidance: The explicit use of image, sketch, and mask as conditional inputs to the diffusion model allows for precise control over the editing process, ensuring that modifications are localized and contextually appropriate.

Key Results

  • Quantitative Improvement: SketchFFusion achieved superior performance on the CelebA-HQ dataset compared to state-of-the-art methods (SC-FEGAN, DeepPS, DeepFill-V2) across objective metrics like FID (9.07 vs. 11.72-14.38), PSNR (26.74 vs. 24.11-24.56), and SSIM (0.8822 vs. 0.8008-0.8740).
  • Qualitative Improvement: Visualizations show that SketchFFusion generates images with better consistency in style and more accurate representation of details, adhering well to the provided sketches.
  • Cross-Dataset Generalization: The model demonstrated its ability to generate images that adhere to structural sketch details even when evaluated on the diverse COCO-AIGC dataset.

Limitations and Future Work

  • Binary Sketches Only: The current model is limited to processing binary sketches and cannot handle colored sketches.
  • Future Work: The authors plan to incorporate colored sketches to enable color editing, expanding the model's capabilities.

Summary updated

Abstract

Sketch-guided image editing aims to achieve local finetuning of the image based on the sketch information provided by the user while maintaining the original status of the unedited areas. Due to the high cost of acquiring human sketches, previous works mostly relied on edge maps as a substitute for sketches. However, sketches possess more rich structural information. In this paper, we propose a sketch generation scheme that can preserve the main contours of an image and closely adhere to the actual sketch style drawn by the user. Simultaneously, current image editing methods often face challenges such as image distortion, training cost, and loss of fine details in the sketch. To address these limitations, We propose a conditional diffusion model (SketchFFusion) based on the sketch structure vector. We evaluate the generative performance of our model and demonstrate that it outperforms existing methods.
BibTeX
@misc{mao2023sketchffusion,
  author = {Weihang Mao and Bo Han and Zihao Wang},
  title = {{Sketchffusion: Sketch-Guided Image Editing with Diffusion Model}},
  year = {2023},
  eprint = {2304.03174},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.03174},
}
Figure