Coursework · Northwestern MSDS 458 (Deep Learning)
Can a CNN spot AI-generated images it wasn’t trained on?
Detectors for AI-generated images often look excellent on the generator they were trained on. I trained convolutional networks to tell real photos from AI-generated ones, checked what they were actually looking at, and then tested whether that skill carries over to newer image generators and to images degraded the way they are when shared online.
Setup
- Training data: CIFAKE, 100K training and 20K test images: real photos versus Stable Diffusion 1.4 images.
- Unseen generators: Flux.1 and Stable Diffusion 3 images from GenImage++, paired with class-matched real ImageNet photos.
- Real-world degradation: the same images resized and re-compressed as JPEG (quality 50), mimicking a re-share on social media.
- Controls: every model was also trained on shuffled labels, and five seeds per setup tested stability.
Are the explanations real?
Grad-CAM heatmaps show where a model is looking, but they can be misleading. To check them, I compared models trained on real labels with models trained on shuffled labels. Real-label models produced attributions that repeated across seeds (correlation about 0.4–0.6); shuffled-label models did not (about 0.01–0.06). So the heatmaps reflect something the models genuinely learned.
The generalization gap
Accuracy fell from about 96% on CIFAKE to about 65% on Flux.1 and SD3, and to about 55% once images were JPEG-compressed. Real photos were still recognized well (75–95% recall); the failure was specifically in recognizing the new generators’ fakes as fake. The gap was nearly identical for two architecturally different generators, so it isn’t a quirk of one model.
Frequency baseline
A classic frequency-domain detector built for GAN-era images reached about 78% on CIFAKE, roughly 18 points below the CNNs. I treated it as a test of whether GAN-era artifacts carry over to diffusion images, not as a verdict on the CNNs.
Takeaway
The networks learned a fingerprint of the generator they were trained on, not a general sense of what makes an image synthetic. Detection that looks solved in-distribution can fall apart as soon as the generator changes or the image is re-shared.