PixPerfect: Seamless Latent Diffusion Local Editing with Discriminative Pixel-Space Refinement

Haitian Zheng, Yuan Yao, Yongsheng Yu, Yuqian Zhou, Jiebo Luo, Zhe Lin

Latent Diffusion Models (LDMs) like Stable Diffusion and FLUX have revolutionized image editing, allowing users to seamlessly remove objects or insert new ones with startling semantic accuracy. However, a close inspection of the edited boundaries often reveals "seams"—subtle color shifts, texture mismatches, or visible lines where the generated pixels meet the original image.

A new paper, PixPerfect, introduces a post-processing framework designed to erase these artifacts, achieving truly seamless local edits across various LDM architectures.

The "Latent Compression" Tax

Most modern image generators operate in a compressed "latent space" rather than directly manipulating pixels. While this makes them computationally efficient, it introduces a significant drawback during the decoding phase. When the model decodes an edited latent region back into pixel space, the reconstruction rarely matches the unedited background perfectly.

This results in three persistent issues:

  1. Chromatic Shifts: The edited area may exhibit a slight color tint (e.g., more yellow or blue) compared to the original photo.
  2. Texture Mismatches: The generated "noise" or film grain often fails to match the original camera sensor's noise profile.
  3. Boundary Seams: Visible discontinuities appear at the edges of the edit mask.

Existing solutions, such as Poisson blending or specialized latent decoders, often struggle with complex textures or require ground-truth data unavailable in real-world scenarios.

The PixPerfect Framework

PixPerfect tackles these issues using a Generative Adversarial Network (GAN) architecture that acts as a single-stage, feed-forward refiner. Because it operates entirely in pixel space, it is model-agnostic—working just as effectively on older Stable Diffusion outputs as it does on the latest FLUX models.

PixPerfect Architecture

The framework relies on three key innovations:

1. Discriminative Pixel Space

Standard loss functions (like L1 or LPIPS) are often "blind" to the subtle color and texture shifts that human eyes easily catch. To solve this, the authors introduce a differentiable tone mapping function.

Discriminative Pixel Space Comparison

During training, this function projects the image into a "discriminative pixel space" where subtle hue and texture discrepancies are mathematically amplified. As seen above, errors that are nearly invisible in standard RGB space become glaringly obvious in the discriminative space, forcing the model to become hyper-sensitive to even the smallest mismatches.

2. Comprehensive Artifact Simulation

Training a refiner requires pairs of "bad" edits and their "perfect" counterparts. Because real diffusion errors are difficult to collect at scale, the researchers built a synthetic pipeline that mimics common LDM failures. This pipeline simulates non-uniform color shifts via gradient blending, texture inconsistencies using JPEG and VAE distortions, and content discontinuities by intentionally perturbing mask boundaries.

3. Inference-Time Pooling

To further stabilize results, the model generates multiple versions of the edit with slight "jitter" at test time. It then uses a consistency metric to select the best-refined output.

Key Insights and Results

The researchers identified a phenomenon they call "Spatial Entanglement." Through controlled experiments, they proved that even if only a tiny portion of a latent representation is altered, the VAE decoder can cause a "global drift" in the background. This confirms that pixel-level refinement is not just helpful, but necessary, as the decoder itself contributes to the problem.

PixPerfect consistently outperforms existing harmonization methods across standard benchmarks (Places2, MISATO, RORDS).

  • Quantitative Boost: On the state-of-the-art FLUX-Fill model, PixPerfect improved the FID (Fréchet Inception Distance, a measure of image realism) from 14.66 to 10.87 on the MISATO dataset.
  • Efficiency: Running on an NVIDIA A100 GPU, the refinement step adds only 2.7 seconds to the workflow. For a FLUX-based edit, this is roughly 21.8% of the total inference time—a small computational cost for a massive leap in visual quality.

Limitations

While PixPerfect is a powerful polishing tool, it cannot fix semantic errors. If the base diffusion model generates a person with six fingers, PixPerfect will ensure those six fingers are perfectly blended and textured into the scene, but it will not remove the extra digit. Additionally, the quality of the refinement is dependent on having a reasonably accurate mask of the edited area.

Ultimately, PixPerfect establishes a new standard for robust, high-fidelity localized image editing, bridging the gap between AI generation and professional-grade photo manipulation.

Summary updated

BibTeX
@inproceedings{zheng2025pixperfect,
  author = {Haitian Zheng and Yuan Yao and Yongsheng Yu and Yuqian Zhou and Jiebo Luo and Zhe Lin},
  title = {{PixPerfect: Seamless Latent Diffusion Local Editing with Discriminative Pixel-Space Refinement}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=hlpRj222RG},
}
Figure