Inspiration

AI-generated images are everywhere now, and most detection benchmarks test models on clean, unmodified images. But real images online almost never stay clean, they get compressed, resized, blurred, and re-shared across platforms. We wanted to build a detector that actually holds up under those conditions, not just performs well in a lab setting.

What it does

SpectraGuard classifies images as AI-generated or authentic, and is specifically built to stay accurate under real-world post-processing: JPEG compression, blurring, resizing, added noise, color jittering, and cropping. Given a directory of images, it outputs a confidence score for each one indicating the likelihood it's AI-generated.

How we built it

We started with CLIP embeddings as a baseline for classification, then added frequency-domain (FFT) features, since AI-generated images often carry detectable artifacts in the frequency spectrum. Fusing these two feature types improved clean accuracy from 88.4% to 90.7%.

But when we stress-tested this fused model against transforms like blur and downsampling, we found it degraded significantly, worse than the CLIP-only model in some cases. Rather than settle for one flawed approach, we built an adaptive gating system: a lightweight blur-detection heuristic estimates how degraded an image is, then routes it to whichever model, CLIP-only or fused, performs better under that specific condition. This adaptive approach matched or exceeded both baselines across nearly every transform we tested, recovering CLIP-only's robustness on heavy blur while keeping fusion's gains on clean and lightly-compressed images.

We also ran a cross-dataset generalization test, evaluating our CIFAKE-trained model zero-shot on SID_Set, a different, higher-resolution dataset. Accuracy dropped sharply (90.6% to ~57%), which taught us an important lesson: robustness to post-processing transforms and robustness to distribution shift are two separate problems, and solving one doesn't solve the other.

Challenges we ran into

  • Diagnosing why fusion hurt robustness. It wasn't obvious at first why adding frequency features would help clean accuracy but hurt under blur, we had to run a full transform-by-transform breakdown to see the pattern clearly before we could design a fix.
  • Cross-dataset generalization. Downloading and integrating SID_Set (a 124GB dataset) taught us firsthand how much real-world data can differ from a curated benchmark like CIFAKE, and how easily a model can overfit to dataset-specific artifacts.
  • Time and resource constraints. Running CLIP feature extraction and full robustness sweeps on CPU meant every experiment took real time to iterate on, which shaped how we prioritized what to test.

What we learned

Robust AI-image detection isn't a single problem, it's at least two: staying accurate under post-processing, and generalizing across different data distributions. Our adaptive gating approach solves the first well, but our honest cross-dataset results show the second remains a much harder open challenge, and one we think deserves more attention in this space.

What's next for SpectraGuard

  • Domain adaptation or fine-tuning across a mix of datasets (CIFAKE, SID_Set, WildFake) to close the generalization gap
  • Investigating frequency-domain features that are less tied to native image resolution
  • Expanding robustness evaluation to the WildFake dataset

Built With

Share this project:

Updates

Submission history