HyperDet: Generalizable Detection of Synthesized Images by Generating and Merging A Mixture of Hyper LoRAs

Huangsen Cao, Yongwei Wang, Yinfeng Liu, Sixian Zheng, Kangtao Lv, Zhimeng Zhang, Bo Zhang, Xin Ding, Fei Wu · Submission to ICLR 2025 · Withdrawn

TL;DR

HyperDet is a generalizable synthetic image detector that adapts a pre-trained vision backbone (CLIP ViT) to spot fake images across unseen GANs and diffusion models. By grouping traditional high-frequency steganalysis filters and using a hypernetwork to dynamically generate specialized LoRA weights, it effectively balances low-level pixel artifacts with semantic context.

What Problem Does This Paper Address?

Rapid progress in generative models—from GANs to modern diffusion models like Midjourney and Stable Diffusion—makes telling synthetic images apart from real photos increasingly difficult. Existing detectors typically suffer from generalization failures:

  1. Low-level pixel detectors (e.g., frequency- or upsampling-artifact detectors) overfit to specific generator footprints and suffer from high false-positive rates on real photos.
  2. High-level semantic detectors (e.g., frozen pre-trained vision-language models) struggle because newer generative models produce semantically coherent and plausible images, leaving few obvious semantic anomalies.

The challenge is designing a detector that captures fine-grained, generalizable pixel artifacts without forgetting the broader semantic context needed to avoid misclassifying real images.

Methods

HyperDet builds upon a pre-trained CLIP (ViT-L/14) backbone and introduces three key innovations:

Input Image ───┬──► [5 Grouped SRM Filters] ──► 5 Filtered Views ──┐
               │                                                  ├─► CLIP ViT (with Hyper LoRAs) ──► Ensembled Classifier
               └──────────────────────────────► Original View    ──┘
  • SRM Filter Grouping: Instead of using all 30 Spatial Rich Model (SRM) steganalysis filters simultaneously, the authors group them into 5 distinct categories based on structural complexity and function (from simple directional edges to complex curved contours and high-order textures). Each group isolates distinct multi-scale, high-frequency artifacts.
  • Hyper LoRAs: Rather than training fixed LoRA adapters or MoE (Mixture of Experts) routers, the framework employs a lightweight hypernetwork. Given task embeddings (which of the 5 filtered views or original image is active), layer depth embeddings (ViT blocks 17–24), and MLP position embeddings, the hypernetwork dynamically predicts the low-rank adapter weights ($W_A, W_B$, rank 16). This forces the hypernetwork to learn shared representations across tasks and layers.
  • Balanced Loss Function: To prevent catastrophic forgetting of natural image distributions, training optimizes a weighted binary cross-entropy loss: $$\mathcal{L} = \alpha \mathcal{L}_{\text{bce}}^{\text{Original}} + (1 - \alpha)\mathcal{L}_{\text{bce}}^{\text{Filtered}}$$ Setting $\alpha = 0.1$ prioritizes subtle texture cues from filtered residual views while anchoring the detector to the original image's semantic features.

Datasets

  • Training Data: 720k images (360k real and 360k synthetic ProGAN images across 20 categories), mirroring standard benchmarks from Wang et al. (2020).
  • Evaluation Benchmarks:
  • UnivFD Benchmark: 19 distinct test sets spanning GANs (StyleGAN, CycleGAN, BigGAN, StarGAN), perceptual-loss synthesis (CRN, IMLE), low-level vision tasks (SITD, SAN), and diffusion models (Glide, LDM, Guided Diffusion, DALL-E).
  • Fake2M Dataset: A challenging benchmark featuring state-of-the-art generators, including Midjourney, CogView2, Stable Diffusion (v1.5 and v2.1), and StyleGAN3.

Key Insights and Ideas

  • Dynamic Adapter Generation Beats Static MoE: A hypernetwork generating LoRA weights achieves higher accuracy (+1.38% over MoE-LoRA) while training and inferring in a unified step, enabling smoother knowledge sharing across different artifact scales.
  • Hierarchical High-Frequency Grouping: Splitting SRM filters prevents noisy interference between subtle directional gradients and high-order textural boundaries, making frequency artifacts much clearer in the Fourier domain.
  • Preserving the "Real" Anchor: Retaining an explicit loss term for the unfiltered original image prevents the network from becoming hypersensitive to noise, directly resolving the high false-positive rate plaguing pixel-only forensics methods.

Key Results

  • UnivFD Benchmark: HyperDet achieves 92.10% average accuracy and 97.90 mAP, outperforming the prior state-of-the-art (MoE for ViT-L/14) by +8.12% accuracy and +0.91 mAP.
  • Fake2M Benchmark: On advanced text-to-image generators, HyperDet surpasses the best-performing baseline (NPR) by +5.03% accuracy and +10.02 mAP.
  • Robustness: HyperDet significantly outperforms competing detectors across all tested levels of Gaussian blur ($\sigma \in \{1, 2, 3, 4\}$) and maintains strong resilience against JPEG compression (qualities 30–90).

Limitations and Future Work

  • Small-Scale Data Sensitivity: When training data drops significantly (e.g., down to 2k samples), accuracy degrades sharply, as hypernetworks overfit and undermine the pre-trained CLIP representations.
  • Heavy JPEG Degradation: Under aggressive JPEG compression, detection performance occasionally falls slightly behind baseline UnivFD.
  • Challenging Generators: The authors note slightly inferior detection performance on Midjourney images within Fake2M relative to other generators in that benchmark.

Summary updated

Abstract

The emergence of diverse generative vision models has recently enabled the synthesis of visually realistic images, underscoring the critical need for effectively detecting these generated images from real photos. Despite advances in this field, existing detection approaches often struggle to accurately identify synthesized images generated by different generative models. In this work, we introduce a novel and generalizable detection framework termed HyperDet, which innovatively captures and integrates shared knowledge from a collection of functionally distinct and lightweight expert detectors. HyperDet leverages a large pretrained vision model to extract general detection features while simultaneously capturing and enhancing task-specific features. To achieve this, HyperDet first groups SRM filters into five distinct groups to efficiently capture varying levels of pixel artifacts based on their different functionality and complexity. Then, HyperDet utilizes a hypernetwork to generate LoRA model weights with distinct embedding parameters. Finally, we merge the LoRA networks to form an efficient model ensemble. Also, we propose a novel objective function that balances the pixel and semantic artifacts effectively. Extensive experiments on the UnivFD and Fake2M datasets demonstrate the effectiveness of our approach, achieving state-of-the-art performance. Moreover, our work paves a new way to establish generalizable domain-specific fake image detectors based on pretrained large vision models. {Our codes are available at \url{https://anonymous.4open.science/r/HyperDet-3053}}.
BibTeX
@misc{cao2024hyperdet,
  author = {Huangsen Cao and Yongwei Wang and Yinfeng Liu and Sixian Zheng and Kangtao Lv and Zhimeng Zhang and Bo Zhang and Xin Ding and Fei Wu},
  title = {{HyperDet: Generalizable Detection of Synthesized Images by Generating and Merging A Mixture of Hyper LoRAs}},
  year = {2024},
  eprint = {2410.06044},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.06044},
}
Figure