Training CNNs in Presence of JPEG Compression: Multimedia Forensics vs Computer Vision

Sara Mandelli, Nicolò Bonettini, Paolo Bestagini, Stefano TubaroarXiv 2020

TL;DR

This paper reveals a critical divergence in how JPEG compression affects deep learning: while standard computer vision models (like object detectors) are largely unfazed by JPEG artifacts, multimedia forensic models (like deepfake detectors) are incredibly fragile. The authors demonstrate that forensic CNNs must be trained with specific JPEG-aware data augmentation—particularly low-quality factor images and misaligned grids—to maintain any real-world generalization capability.

What Problem Does This Paper Address?

Convolutional Neural Networks (CNNs) have revolutionized both computer vision (CV) and multimedia forensics. However, these two fields look at images through very different lenses. CV models focus on semantic cues—the shapes and textures that allow a human to recognize a cat or a car. Forensic models, conversely, hunt for invisible traces—microscopic noise patterns from camera sensors or mathematical artifacts left by GANs.

The problem is that common image processing, specifically JPEG compression, acts as a "noise" that can easily wipe out these subtle forensic traces. The authors investigate two specific JPEG-related hurdles:

  1. Grid Misalignment: JPEG operates on an 8x8 pixel grid. If an image is cropped and re-saved, this grid shifts.
  2. Quality Factor (QF) Mismatch: A model trained on high-quality images might fail completely when faced with the heavy compression typical of social media platforms.

Methods

The researchers conducted a systematic comparison across four different CNN architectures (EfficientNetB0, EfficientNetB4, ResNet50, and XceptionNet) to ensure their findings weren't biased by a specific model design.

They tested these models on four distinct tasks:

  • Forensics: Camera model identification and CNN-generated (CycleGAN) image detection.
  • Computer Vision: Object classification on subsets of ImageNet and LSUN.

The experimental setup involved varying the training and testing conditions by intentionally misaligning the JPEG grid (through random cropping) and testing a wide range of JPEG Quality Factors ($QF \in \{50, 60, 70, 80, 90, 99\}$).

Datasets

  • Vision Dataset: Used for camera model identification, featuring 28 different camera models.
  • CycleGAN Dataset: Used for detecting synthetically generated images vs. pristine photographs.
  • ImageNet: A standard CV benchmark; the authors used a subset of 16 synsets.
  • LSUN: A large-scale scene understanding dataset; the authors used a subset of 20 categories.

Key Insights and Ideas

  • Semantic Robustness vs. Forensic Fragility: CV models are robust because the "meaning" of an image doesn't change with compression. Forensic models are fragile because their "features" are often high-frequency signals that JPEG quantization specifically targets for removal.
  • The "Nuisance" of the Grid: For forensics, the 8x8 JPEG grid is not just a detail; it's a fundamental part of the signal. If a model is trained only on "aligned" grids (where the 8x8 blocks start at pixel 0,0), it fails to generalize to the "misaligned" grids created by simple cropping.
  • Training for the Worst Case: In forensics, training on low-quality images ($QF=50$) actually helps the model perform better across all quality levels. Training on high-quality data ($QF=99$) is almost equivalent to not using any augmentation at all, leading to poor generalization.

Key Results

The disparity between CV and forensics is stark. As shown in Figure 1, when a forensic model (like Camera ID) is trained on aligned patches but tested on misaligned ones, accuracy drops significantly (from near-perfect to below 0.71). In contrast, the CV models (ImageNet/Lsun) show virtually no change in performance regardless of grid alignment.

Accuracy as a function of JPEG-grid alignment. Note the significant drops in forensic tasks (a, b) compared to the stability of CV tasks (c, d).

Regarding Quality Factors, the authors found that forensic models trained without compression augmentation are essentially useless in the wild. For camera identification, accuracy can plummet to below 0.2 if the test QF doesn't match the training QF. However, by augmenting the training set with $QF=50$ images, accuracy can be recovered to over 0.85 across the board.

Fig. 4. Accuracy of ResNet50 as a function of training augmentation for the tasks of (a) camera model identification, (b) CNN-generated image detection, (c) image classification on ImageNet and Lsun subsets.

Limitations and Future Work

The paper focuses exclusively on JPEG compression. While JPEG is ubiquitous, other common operations like resizing (resampling), median filtering, or contrast enhancement also leave traces and could be studied in a similar comparative framework. The authors suggest that future forensic research must be extremely cautious about these "global processing traces" to ensure that models are learning the actual forensic task rather than just becoming overfitted to specific compression settings.

Summary updated

BibTeX
@misc{mandelli2020training,
  author = {Sara Mandelli and Nicolò Bonettini and Paolo Bestagini and Stefano Tubaro},
  title = {{Training CNNs in Presence of JPEG Compression: Multimedia Forensics vs Computer Vision}},
  year = {2020},
  eprint = {2009.12088},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2009.12088},
}
Figure