Generalizable AI-Generated Image Detection Using Baseline CNN Models
Train reproducible baseline classifiers for real-vs-AI image detection before merging in stronger multi-branch detector work.
The current local code keeps the baseline script as the main entry point and only factors augmentation/preprocessing into a small helper module for easier future merging.
src/train_baseline.py: baseline training and evaluation scriptsrc/data_augmentation.py: RGB conversion, resizing, normalization, and optional light training augmentationoutputs/: saved local experiment outputs and checkpoints
Default dataset root:
dataset/
Expected CIFAKE layout under --dataset-root:
dataset/
cifake/
train/
REAL/
FAKE/
test/
REAL/
FAKE/
TinyGenImage combined training expects this layout under --dataset-root:
dataset/
tiny-genimage/
imagenet_ai_0419_biggan/
train/
ai/
nature/
val/
ai/
nature/
...
Labels:
REAL/nature=0FAKE/ai=1
python -m pip install -r requirements.txtSimple CNN on CIFAKE:
python src/train.py --dataset-root dataset --datasets cifakeResNet-18 on CIFAKE:
python src/train.py --dataset-root dataset --datasets cifake --model resnet18 --epochs 10 --batch-size 128CIFAKE + TinyGenImage:
python src/train.py --dataset-root dataset --datasets cifake tiny-genimage --model resnet18 --epochs 10 --batch-size 128TinyGenImage only:
python src/train.py --dataset-root dataset --datasets tiny-genimage --model resnet18 --epochs 10 --batch-size 64 --semantic-size 224 --normalization imagenetTinyGenImage only, filtered to one generator:
python src/train.py --dataset-root dataset --datasets tiny-genimage --generators sdv5 --model resnet18 --epochs 10 --batch-size 64 --semantic-size 224 --normalization imagenetTraining option names:
python src/train.py --dataset-root dataset --datasets cifake --lr 0.001 --semantic-size 32 --max-train-samples 128 --max-val-samples 64Enable light training-only augmentation:
python src/train.py --dataset-root dataset --datasets cifake --augmentRun a tiny overfit sanity check:
python src/train.py --dataset-root dataset --datasets cifake --tiny-overfit --epochs 20 --batch-size 32Examples
python src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset cifakepython src/evaluation.py --checkpoint outputs/simple_cnn/best_model.pt --dataset tiny-genimage --tinygenimage-split valpython src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset combinedRun clean evaluation plus JPEG compression, Gaussian blur, down-up resize, and Gaussian noise:
python src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset cifake --distortions all --output outputs/resnet18/robustness_cifake.jsonRun selected distortions only:
python src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset tiny-genimage --tinygenimage-split val --distortions clean jpeg_q70 blur noise