Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ML Final Project

Project

Generalizable AI-Generated Image Detection Using Baseline CNN Models

Goal

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.

Files

  • src/train_baseline.py: baseline training and evaluation script
  • src/data_augmentation.py: RGB conversion, resizing, normalization, and optional light training augmentation
  • outputs/: saved local experiment outputs and checkpoints

Dataset Layout

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 = 0
  • FAKE / ai = 1

Setup

python -m pip install -r requirements.txt

Train

Simple CNN on CIFAKE:

python src/train.py --dataset-root dataset --datasets cifake

ResNet-18 on CIFAKE:

python src/train.py --dataset-root dataset --datasets cifake --model resnet18 --epochs 10 --batch-size 128

CIFAKE + TinyGenImage:

python src/train.py --dataset-root dataset --datasets cifake tiny-genimage --model resnet18 --epochs 10 --batch-size 128

TinyGenImage only:

python src/train.py --dataset-root dataset --datasets tiny-genimage --model resnet18 --epochs 10 --batch-size 64 --semantic-size 224 --normalization imagenet

TinyGenImage 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 imagenet

Training option names:

python src/train.py --dataset-root dataset --datasets cifake --lr 0.001 --semantic-size 32 --max-train-samples 128 --max-val-samples 64

Enable light training-only augmentation:

python src/train.py --dataset-root dataset --datasets cifake --augment

Run a tiny overfit sanity check:

python src/train.py --dataset-root dataset --datasets cifake --tiny-overfit --epochs 20 --batch-size 32

Individual Evaluation

Evaluate Model with ONE DATASET only

Examples

python src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset cifake
python src/evaluation.py --checkpoint outputs/simple_cnn/best_model.pt --dataset tiny-genimage --tinygenimage-split val

Combined Test

python src/evaluation.py --checkpoint outputs/resnet18/best_model.pt --dataset combined

Robustness Evaluation

Run 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.json

Run 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages