Abstract: Diffusion models (DMs) memorize training images and can reproduce near-duplicates during generation. Current detection methods identify verbatim memorization but fail to capture two critical aspects: quantifying partial memorization occurring in small image regions, and memorization patterns beyond specific prompt-image pairs. To address these limitations, we propose Foreground Background Memorization (FB-Mem), a novel segmentation-based metric that classifies and quantifies memorized regions within generated images. Our method reveals that memorization is more pervasive than previously understood: (1) individual generations from single prompts may be linked to clusters of similar training images, revealing complex memorization patterns that extend beyond one-to-one correspondences; and (2) existing model-level mitigation methods, such as neuron deactivation and pruning, fail to eliminate local memorization, which persists particularly in foreground regions. Our work establishes an effective framework for measuring memorization in diffusion models, demonstrates the inadequacy of current mitigation approaches, and proposes a stronger mitigation method using a clustering approach.
The Challenge of Partial Memorization
Generative AI models suffer from a persistent "copy-paste" problem, where they memorize and reproduce specific images from their training sets. While existing tools can detect verbatim (exact) copies, they often overlook partial memorization. A model might, for instance, perfectly recreate a copyrighted character in the foreground while placing it in an entirely original background.
Traditional detection methods also assume a simplistic one-to-one relationship between a prompt and a training image. This narrow view underestimates the privacy and copyright risks inherent in models like Stable Diffusion. Furthermore, standard "unlearning" techniques often fail to scrub these localized traces of training data, particularly when they are embedded in the foreground of an image.
FB-Mem: A Fine-Grained Metric
To provide a more nuanced understanding of this phenomenon, we introduce FB-Mem (Foreground-Background Memorization). This segmentation-based metric decomposes image memorization into distinct components. Using a segmentation model to separate the subject from its setting, the algorithm calculates similarity scores (via MS-SSIM) for the full image, the foreground, and the background independently.
This approach allows generated images to be classified into four categories:
- Verbatim Memorization (VM): The entire image is a near-match to a training sample.
- Foreground Memorization (FM): Only the primary subject is memorized.
- Background Memorization (BM): Only the setting or style is memorized.
- Not Memorized (NM): The image is sufficiently original.
Our evaluation shows that FB-Mem, utilizing MS-SSIM, achieves high accuracy (0.913) in distinguishing these types, outperforming standard metrics like SSCD in detecting partial/local memorization while being significantly faster to compute.
Complex Memorization Patterns
Our research reveals that memorization is far more complex than a simple prompt-to-image mapping. We discovered a "one-to-many" relationship: a single prompt can generate variations that match up to 17 different distinct training images. This suggests that memorization exists as a dense neighborhood in the model's latent space rather than isolated points.
Crucially, we found that the foreground is "stickier" than the background. Existing mitigation methods, such as pruning or neuron deactivation, are often effective at cleaning up background memorization but frequently leave the foreground intact. This is particularly concerning as the foreground typically contains the most sensitive or copyrighted information.
NeMo-C: Cluster-Based Mitigation
To address these persistent traces, we propose NeMo-C (Cluster-based Mitigation). Building on previous neuron-deactivation methods, NeMo-C recognizes that memorization occurs at a "concept" level. By clustering semantically similar prompts and identifying the union of neurons contributing to memorization across the entire cluster, NeMo-C can more effectively scrub memorized content.
In our tests, NeMo-C achieved a Mitigation Strength score of 0.83, significantly higher than other state-of-the-art methods like NeMo (0.74) or Wanda (0.79). Importantly, NeMo-C maintains high image quality, proving that it is possible to "unlearn" specific training data without compromising the model's general creative utility.
Conclusion
By demystifying the local nature of memorization, FB-Mem provides a necessary framework for auditing diffusion models. Our findings highlight the inadequacy of current one-to-one detection and mitigation strategies, pointing toward cluster-based approaches like NeMo-C as a more robust path forward for protecting privacy and intellectual property in generative AI.
Summary updated