How angelperezcastro/ai-image-detection works
This is a PyTorch pipeline for classifying images as AI-generated or real. Users can combine or sample generator datasets, train a ConvNeXt-Tiny classifier, evaluate it, run single-image predictions, and generate Grad-CAM overlays. Training and evaluation share the dataset loader and model utilities; inference and Grad-CAM independently load checkpoints through the same model utilities. The graph reflects the documented dataset-building capabilities; source for those scripts was sampled, while other unsampled subsystems are represented only where the README and tree support them.
Main entry points: train.py Training pipeline · evaluate.py Evaluation pipeline · gradcam_infer.py Grad-CAM inference · dataset.py Dataset loader
Components 15
Dataset preparation
- Generator datasets
data/raw - Sample builder
scripts/create_samples.py - Full combiner
scripts/create_full_all.py - Sample dataset
data/samples
Training and evaluation
- Dataset loader
src/dataset.py - Training pipeline
src/train.py - Evaluation pipeline
src/evaluate.py - Metrics and figures
results/metrics
Model and checkpoints
- ConvNeXt model
src/model.py - Model checkpoints
models/saved_models
Prediction and explanation
- Image inference
src/infer.py - Grad-CAM inference
src/gradcam_infer.py - Grad-CAM overlays
results/gradcams
Other components
- User
- Input image
Connections 26
- User → Sample builder: runs
- User → Full combiner: runs
- Sample builder → Generator datasets: reads images
- Sample builder → Sample dataset: copies samples
- Full combiner → Generator datasets: reads and writes
- User → Training pipeline: starts training
- Training pipeline → Dataset loader: loads batches
- Dataset loader → Generator datasets: reads images
- Dataset loader → Sample dataset: reads images
- Training pipeline → ConvNeXt model: builds model
- Training pipeline → Model checkpoints: saves checkpoints
- Training pipeline → Metrics and figures: writes metrics
- User → Evaluation pipeline: starts evaluation
- Evaluation pipeline → Dataset loader: loads validation data
- Evaluation pipeline → ConvNeXt model: builds model
- Evaluation pipeline → Model checkpoints: loads checkpoint
- Evaluation pipeline → Metrics and figures: writes reports
- User → Image inference: requests prediction
- User → Grad-CAM inference: requests explanation
- Input image → Image inference: provides image
- Input image → Grad-CAM inference: provides image
- Image inference → ConvNeXt model: builds model
- Image inference → Model checkpoints: loads checkpoint
- Grad-CAM inference → ConvNeXt model: builds model
- Grad-CAM inference → Model checkpoints: loads checkpoint
- Grad-CAM inference → Grad-CAM overlays: writes overlay