# mandeep15686/ai-vs-real-image-detection architecture

> Architecture diagram of the GitHub repository mandeep15686/ai-vs-real-image-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mandeep15686/ai-vs-real-image-detection
- Repository: https://github.com/mandeep15686/ai-vs-real-image-detection

## Overview

This repository is an end-to-end AI-generated-versus-real image detection project. Its main workflow audits, validates, deduplicates, standardizes, analyzes, and splits image data; trains classifiers; evaluates them; and predicts labels for new images. A parallel DCGAN workflow generates synthetic images and can integrate them into the training split. The graph follows documented workflow relationships; source excerpts are partial, so implementation-level links not established by those excerpts are omitted.

Main entry points: [`step1_data_audit.py`](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step1_data_audit.py) (Dataset audit), [`predict.py`](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/predict.py) (CLI prediction), [`quick_check.py`](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/quick_check.py) (Interactive image check), [`step2_validate_images.py`](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step2_validate_images.py) (Image validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_audit["Dataset audit"]
  node_validate["Image validation"]
  node_deduplicate["Duplicate removal"]
  node_standardize["Image standardization"]
  node_eda["Exploratory analysis<br/>[step5_eda.py]"]
  node_split["Dataset splitting"]
end

subgraph group_gan["GAN augmentation"]
  node_gan["DCGAN training and generation<br/>[gan_generator.py]"]
  node_gan_eval["GAN quality and integration<br/>[gan_evaluate.py]"]
end

subgraph group_models["Modeling and evaluation"]
  node_train["Classifier training<br/>[train_model.py]"]
  node_evaluate["Test-set evaluation<br/>[evaluate_model.py]"]
end

subgraph group_inference["Image inference"]
  node_predict["CLI prediction<br/>[predict.py]"]
  node_quick_check["Interactive image check<br/>[quick_check.py]"]
end

node_operator(("Project operator"))
node_source_images[("Source images")]
node_prepared_data[("Prepared image splits")]
node_models_store[("Model checkpoints")]
node_verdict["Image verdict"]

node_operator -->|"runs"| node_audit
node_source_images -->|"audits"| node_audit
node_audit -->|"precedes"| node_validate
node_validate -->|"precedes"| node_deduplicate
node_deduplicate -->|"precedes"| node_standardize
node_standardize -->|"analyzes"| node_eda
node_eda -->|"precedes"| node_split
node_split -->|"creates splits"| node_prepared_data
node_operator -->|"trains or generates"| node_gan
node_gan -->|"provides samples"| node_gan_eval
node_gan_eval -->|"integrates samples"| node_prepared_data
node_prepared_data -->|"trains from"| node_train
node_train -->|"saves checkpoints"| node_models_store
node_models_store -->|"evaluates models"| node_evaluate
node_prepared_data -->|"tests against"| node_evaluate
node_operator -->|"submits image"| node_predict
node_operator -->|"enters image"| node_quick_check
node_models_store -->|"loads models"| node_predict
node_models_store -->|"loads models"| node_quick_check
node_predict -->|"returns prediction"| node_verdict
node_quick_check -->|"prints prediction"| node_verdict

click node_audit "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step1_data_audit.py"
click node_validate "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step2_validate_images.py"
click node_deduplicate "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step3_remove_duplicates.py"
click node_standardize "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step4_standardise_images.py"
click node_eda "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step5_eda.py"
click node_split "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step6_train_val_test_split.py"
click node_gan "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/gan_generator.py"
click node_gan_eval "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/gan_evaluate.py"
click node_train "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/train_model.py"
click node_evaluate "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/evaluate_model.py"
click node_predict "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/predict.py"
click node_quick_check "https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/quick_check.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_audit,node_validate,node_deduplicate,node_standardize,node_eda,node_split toneBlue
class node_gan,node_gan_eval,node_source_images,node_prepared_data,node_models_store toneAmber
class node_train,node_evaluate toneMint
class node_predict,node_quick_check toneRose
class node_operator,node_verdict toneIndigo
```

## Components

### Data preparation

- [Dataset audit](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step1_data_audit.py): `step1_data_audit.py`
- [Image validation](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step2_validate_images.py): `step2_validate_images.py`
- [Duplicate removal](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step3_remove_duplicates.py): `step3_remove_duplicates.py`
- [Image standardization](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step4_standardise_images.py): `step4_standardise_images.py`
- [Exploratory analysis](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step5_eda.py): `step5_eda.py`
- [Dataset splitting](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/step6_train_val_test_split.py): `step6_train_val_test_split.py`

### GAN augmentation

- [DCGAN training and generation](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/gan_generator.py): `gan_generator.py`
- [GAN quality and integration](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/gan_evaluate.py): `gan_evaluate.py`

### Modeling and evaluation

- [Classifier training](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/train_model.py): `train_model.py`
- [Test-set evaluation](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/evaluate_model.py): `evaluate_model.py`

### Image inference

- [CLI prediction](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/predict.py): `predict.py`
- [Interactive image check](https://github.com/mandeep15686/ai-vs-real-image-detection/blob/main/quick_check.py): `quick_check.py`

### Other components

- **Project operator**
- **Source images**
- **Prepared image splits**
- **Model checkpoints**
- **Image verdict**

## Connections

- Project operator → Dataset audit: runs (evidence: `README.md`)
- Source images → Dataset audit: audits (evidence: `README.md`)
- Dataset audit → Image validation: precedes (evidence: `README.md`)
- Image validation → Duplicate removal: precedes (evidence: `README.md`)
- Duplicate removal → Image standardization: precedes (evidence: `README.md`)
- Image standardization → Exploratory analysis: analyzes (evidence: `README.md`)
- Exploratory analysis → Dataset splitting: precedes (evidence: `README.md`)
- Dataset splitting → Prepared image splits: creates splits (evidence: `README.md`)
- Project operator → DCGAN training and generation: trains or generates (evidence: `README.md`)
- DCGAN training and generation → GAN quality and integration: provides samples (evidence: `README.md`)
- GAN quality and integration → Prepared image splits: integrates samples (evidence: `README.md`)
- Prepared image splits → Classifier training: trains from (evidence: `README.md`)
- Classifier training → Model checkpoints: saves checkpoints (evidence: `README.md`)
- Model checkpoints → Test-set evaluation: evaluates models (evidence: `README.md`)
- Prepared image splits → Test-set evaluation: tests against (evidence: `README.md`)
- Project operator → CLI prediction: submits image (evidence: `README.md`)
- Project operator → Interactive image check: enters image (evidence: `README.md`)
- Model checkpoints → CLI prediction: loads models (evidence: `README.md`)
- Model checkpoints → Interactive image check: loads models (evidence: `README.md`)
- CLI prediction → Image verdict: returns prediction (evidence: `README.md`)
- Interactive image check → Image verdict: prints prediction (evidence: `README.md`)
