TL;DR
This paper introduces DiffSim, a novel method for evaluating visual similarity in generative AI by leveraging the attention mechanisms within pre-trained diffusion models. DiffSim achieves state-of-the-art performance by better aligning with human judgment than existing metrics, particularly for customized generation tasks.
What Problem Does This Paper Address?
Evaluating the quality of generated images, especially in customized generation tasks (e.g., modifying an existing image or generating variations), is crucial. Traditional metrics often fall short because they focus on low-level pixel or patch comparisons, failing to capture higher-level semantic and structural similarities that humans naturally perceive. While recent methods like CLIP and DINO use semantic features, they heavily compress image information, leading to a loss of detail and sometimes misaligned judgments with human perception. Existing human-aligned methods often require extensive training data and struggle with generalization. There's a clear need for a more robust, generalizable, and human-aligned visual similarity metric for generative AI.
Methods
The core of DiffSim lies in its use of the Aligned Attention Score (AAS), which leverages the attention mechanisms within diffusion models (specifically, the U-Net architecture). The key idea is that attention layers implicitly align features between images, capturing both semantic and stylistic relationships without requiring explicit pixel-level correspondence.
DiffSim offers two main implementations:
- DiffSim-S (Self-Attention): This method utilizes the self-attention layers of the U-Net. It extracts features from two images (IA and IB) at a specific layer and timestep, then computes AAS by aligning the query features of one image with the key and value features of the other. This is particularly effective for capturing appearance similarity.
- DiffSim-C (Cross-Attention): This approach uses cross-attention layers, often enhanced with IP-Adapter Plus. IP-Adapter injects image-specific tokens into the cross-attention mechanism, allowing for a more nuanced interaction between image features and prompt embeddings. This method is designed to capture more complex relationships, including those influenced by text prompts.
AAS itself is calculated by taking the cosine similarity between the attention-computed features of two images, ensuring that each image's features are considered both as queries and keys against the other. This integrated approach aims to overcome misalignment issues and preserve rich feature information.
The authors also demonstrate that this AAS mechanism can be adapted to other architectures like CLIP and DINO, creating "CLIP AAS" and "DINO v2 AAS" metrics.
Datasets
The paper introduces two new benchmarks:
- Sref Bench: Designed to evaluate style similarity. It consists of 508 styles, each with four reference images generated using Midjourney's "sref" mode, which allows users to guide style using external images.
- IP Bench: Created to assess instance-level consistency, particularly for character generation. It includes images of 299 IP characters with variations exhibiting decreasing similarity.
Existing benchmarks used for evaluation include:
- NIGHTS Perceptual Dataset
- TID2013
- CUTE Benchmark
- Dreambench++
- InstantStyle Benchmark
- TikTok Dataset (for video appearance consistency)
- MS COCO Test Dataset (for image retrieval)
Key Insights and Ideas
- Diffusion Model Attention is Key: The paper's central insight is that the attention mechanisms within diffusion models, which are crucial for generating coherent images, can be repurposed to evaluate image similarity. This is a novel application of these powerful generative models.
- Implicit Alignment is Powerful: AAS effectively addresses the problem of misalignment between images (due to pose, style, or context changes) by using attention to implicitly align features, a significant improvement over methods that assume pixel-level correspondence.
- Layer and Timestep Matter: Different layers and denoising timesteps within the U-Net capture different aspects of similarity. Shallower layers and higher timesteps are better for style, while deeper layers and lower timesteps are better for instance-level similarity. This allows for flexible tuning of DiffSim.
- AAS Generalizes: The AAS concept isn't limited to diffusion models; it can enhance existing metrics like CLIP and DINO by providing a more sophisticated feature alignment mechanism.
- Human Alignment is Achievable: DiffSim demonstrates a strong correlation with human judgments, outperforming or matching existing state-of-the-art methods on human consistency benchmarks.
Key Results
- DiffSim achieves state-of-the-art performance across multiple benchmarks, including NIGHTS, CUTE, TID2013, Sref, and InstantStyle bench.
- On the Sref bench, DiffSim achieved 97.40% accuracy, significantly outperforming baselines like LPIPS (87.85%) and Gram (84.05%).
- On the IP bench, DiffSim achieved 92.04% accuracy, leading other methods.
- DiffSim shows superior alignment with human perceptual consistency on the NIGHTS dataset (86.52%) and is comparable to DINO v2 on Dreambench++.
- The adapted metrics, CLIP AAS and DINO v2 AAS, show improvements over their original counterparts on specific benchmarks.
- An ensemble model combining CLIP, DINO v2, and DiffSim further boosted performance, demonstrating DiffSim's complementary nature.
Limitations and Future Work
- Background Overemphasis: DiffSim can sometimes overemphasize background features, potentially neglecting key subject details, especially in images with smaller subjects. The authors suggest cropping the subject as a mitigation strategy.
- Resolution Impact: While generally robust, performance on the NIGHTS dataset did not benefit from higher inference resolutions, unlike IP and Sref benches. The authors standardize to 512x512 for consistency with Stable Diffusion 1.5.
- Model Size: As diffusion models increase in size (e.g., SD-XL), attention values can become more diffuse, potentially hindering DiffSim's performance.
- Future Work: The paper suggests exploring additional model architectures (like Diffusion Transformers) and further investigating the impact of different layers and timesteps for fine-grained control. The authors also plan to release their code.
Summary updated