Diffusion models have shown remarkable success in visual synthesis, but have also raised concerns about potential abuse for malicious purposes. In this paper, we seek to build a detector for telling apart real images from diffusion-generated images. We find that existing detectors struggle to detect images generated by diffusion models, even if we include generated images from a specific diffusion model in their training data. To address this issue, we propose a novel image representation called DIffusion Reconstruction Error (DIRE), which measures the error between an input image and its reconstruction counterpart by a pre-trained diffusion model. We observe that diffusion-generated images can be approximately reconstructed by a diffusion model while real images cannot. It provides a hint that DIRE can serve as a bridge to distinguish generated and real images. DIRE provides an effective way to detect images generated by most diffusion models, and it is general for detecting generated images from unseen diffusion models and robust to various perturbations. Furthermore, we establish a comprehensive diffusion-generated benchmark including images generated by eight diffusion models to evaluate the performance of diffusion-generated image detectors. Extensive experiments on our collected benchmark demonstrate that DIRE exhibits superiority over previous generated-image detectors. The code and dataset are available at https://github.com/ZhendongWang6/DIRE.
翻译:扩散模型在视觉合成领域取得了显著成功,但也引发了对可能被恶意滥用的担忧。本文旨在构建一个检测器,用于区分真实图像与扩散模型生成的图像。我们发现现有检测器难以识别扩散模型生成的图像,即使在其训练数据中包含特定扩散模型生成的图像也是如此。为解决这一问题,我们提出了一种名为扩散重建误差(DIRE)的新型图像表示方法,该方法通过预训练的扩散模型测量输入图像与其重建版本之间的误差。我们观察到,扩散模型生成的图像可以被该模型近似重建,而真实图像则不能。这表明DIRE可作为区分生成图像与真实图像的桥梁。DIRE为检测大多数扩散模型生成的图像提供了有效途径,且能泛化至未见过的扩散模型,并对多种扰动具有鲁棒性。此外,我们构建了一个包含八种扩散模型生成图像的综合性基准数据集,用于评估扩散生成图像检测器的性能。在收集的基准数据集上的大量实验表明,DIRE相较于以往生成图像检测器具有优越性。代码与数据集详见https://github.com/ZhendongWang6/DIRE。