MoEdit: On Learning Quantity Perception for Multi-object Image Editing

Yanfeng Li, Ka-Hou Chan, Yue Sun, Chan-Tong Lam, Tong Tong, Zitong Yu, Keren Fu, Xiaohong Liu, Tao Tan

Abstract

While Diffusion Models have achieved remarkable success in image generation and editing, they frequently struggle with multi-object scenarios, leading to "attribute aliasing" and "quantity inconsistency." MoEdit is a novel, auxiliary-free framework designed to solve these issues. By introducing two specialized modules—Feature Compensation (FeCom) and Quantity Attention (QTTN)—MoEdit enables precise multi-object editing that preserves the exact number of entities and prevents attribute bleeding without the need for manual masks, bounding boxes, or external guidance tools.

Introduction

State-of-the-art diffusion models like Stable Diffusion XL (SDXL) have revolutionized the field of image editing. However, their performance degrades significantly when processing scenes containing multiple objects. Two primary failure modes emerge: attribute aliasing, where features from one object (e.g., a fox's ears) are incorrectly applied to another (e.g., a rabbit), and inconsistent quantity perception, where the model fails to maintain the correct count of objects during an edit.

Existing solutions often attempt to mitigate these issues using auxiliary tools such as Large Language Models (LLMs) for layout planning or manual segmentation masks. These methods are often computationally expensive, require human intervention, and can fail to capture the global context of the original image. MoEdit addresses these challenges by learning quantity perception directly within the diffusion process, offering a streamlined, "auxiliary-free" pipeline.

Methodology

MoEdit is built upon the SDXL architecture and introduces two core components designed to enhance the model's understanding of multi-object scenes.

Feature Compensation (FeCom) Module

The researchers identified that the standard CLIP image-text encoder often produces "interlaced" features in multi-object scenes, making it difficult for the model to distinguish individual object boundaries. The FeCom module addresses this by using the text prompt—which contains explicit quantity information—to "compensate" for these inferior image features. Through a cross-attention mechanism, FeCom ensures that object attributes remain distinct and separable before the denoising process begins. A critical finding in the development of FeCom was the necessity of LayerNorm; without it, the compensation features either fail to resolve aliasing or overwhelm the original image's structural details.

Quantity Attention (QTTN) Module

The QTTN module serves as the system’s internal "counter." Injected into the 4th transformer block (B4) of the U-Net—a location identified as the "Goldilocks" point for balancing global structure and high-resolution editability—QTTN perceives objects both as individual entities and as part of a collective whole. By controlling attention maps during the denoising process, QTTN ensures that the number of objects in the output remains consistent with the input, even during complex "object reinvention" tasks (e.g., turning a group of birds into turkeys).

Training Strategy

The system is trained using a reconstruction loss where editing instructions are set to "null-text." This allows the FeCom and QTTN modules to isolate and learn quantity perception independently of specific style or species changes. During training, the base SDXL weights remain frozen, ensuring the model retains its broad generative capabilities.

Experimental Evaluation

MoEdit was evaluated using a dataset of over 1,200 multi-object images with high object density (3 to 14 objects per image). The model was compared against seven state-of-the-art (SOTA) methods, including TurboEdit, Emu2, and IP-Adapter, across a benchmark of 3,000 generated images.

Key Results

  • Numerical Accuracy: MoEdit significantly outperformed competitors in maintaining object counts, particularly in crowded scenes (9+ objects).
  • Visual Quality: On the Q-Align metric, MoEdit demonstrated a 5.82% improvement in aesthetic and visual quality over previous methods.
  • Subjective Preference: User studies indicated a strong preference for MoEdit, specifically highlighting its ability to perform radical object changes while keeping the background and surrounding context perfectly stable.

Discussion and Limitations

One of the most significant insights from the MoEdit research is the fragility of standard CLIP features in multi-object contexts. By demonstrating how easily object attributes alias when subjected to minor noise, the authors justified the necessity of a dedicated compensation mechanism.

Despite its strengths in counting and attribute separation, MoEdit inherits certain limitations from its base model, specifically regarding 3D spatial reasoning. The model may occasionally struggle with complex depth relationships, such as objects appearing to float or clip through surfaces. Future work will likely focus on integrating 3D environmental data to improve spatial alignment and coherence in dense scenes.

Conclusion

MoEdit represents a significant step forward in multi-object image editing. By moving away from cumbersome auxiliary tools and focusing on internal feature compensation and quantity-aware attention, it provides a robust solution for maintaining numerical and attribute integrity in complex visual edits.

Summary updated

BibTeX
@inproceedings{li2025moedit,
  author = {Yanfeng Li and Ka-Hou Chan and Yue Sun and Chan-Tong Lam and Tong Tong and Zitong Yu and Keren Fu and Xiaohong Liu and Tao Tan},
  title = {{MoEdit: On Learning Quantity Perception for Multi-object Image Editing}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.00256},
}
Figure