# watson752/ai_detection_model architecture

> Architecture diagram of the GitHub repository watson752/ai_detection_model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/watson752/ai_detection_model
- Repository: https://github.com/watson752/ai_detection_model

## Overview

This repository is a glioma-versus-healthy MRI slice classification workflow. Users place MRI data in the configured raw-data folders, build normalized central-slice datasets, train a CNN, then evaluate it or inspect predictions with Grad-CAM. The graph includes the documented evaluation and interpretability branches. Source excerpts show the main calls and file exchanges; raw-data placement and command entry points are documented in the README.

Main entry points: [`src/train.py`](https://github.com/watson752/ai_detection_model/blob/main/src/train.py) (Training workflow), [`src/config.py`](https://github.com/watson752/ai_detection_model/blob/main/src/config.py) (Path and image config), [`src/evaluate.py`](https://github.com/watson752/ai_detection_model/blob/main/src/evaluate.py) (Test evaluation), [`src/grad_cam.py`](https://github.com/watson752/ai_detection_model/blob/main/src/grad_cam.py) (Grad-CAM visualization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["MRI preparation"]
  node_dataset_job["Dataset builder<br/>[make_dataset.py]"]
  node_dicom_prep["DICOM preprocessing<br/>[data_prep.py]"]
  node_processed_data[("Processed arrays")]
end

subgraph group_learning["Model training"]
  node_training["Training workflow<br/>[train.py]"]
  node_cnn["Binary CNN<br/>[model.py]"]
  node_model_store[("Saved models")]
end

subgraph group_analysis["Evaluation and interpretation"]
  node_evaluation["Test evaluation<br/>[evaluate.py]"]
  node_metrics["Classification metrics<br/>[evaluate.py]"]
  node_gradcam["Grad-CAM visualization<br/>[grad_cam.py]"]
  node_heatmap["MRI heatmap overlay<br/>[grad_cam.py]"]
end

subgraph group_runtime["Shared configuration"]
  node_config["Path and image config<br/>[config.py]"]
end

node_user(("Dataset user"))
node_raw_mri[("Raw MRI data")]

node_user -->|"places scans"| node_raw_mri
node_user -->|"runs"| node_dataset_job
node_dataset_job -->|"builds classes"| node_dicom_prep
node_dicom_prep -->|"reads DICOM"| node_raw_mri
node_dataset_job -->|"writes arrays"| node_processed_data
node_dataset_job -->|"uses paths"| node_config
node_dicom_prep -->|"uses image size"| node_config
node_user -->|"runs"| node_training
node_training -->|"loads arrays"| node_processed_data
node_training -->|"writes test split"| node_processed_data
node_training -->|"builds model"| node_cnn
node_training -->|"saves checkpoints"| node_model_store
node_training -->|"uses paths"| node_config
node_cnn -->|"uses dimensions"| node_config
node_user -->|"runs"| node_evaluation
node_evaluation -->|"loads test data"| node_processed_data
node_evaluation -->|"loads best model"| node_model_store
node_evaluation -->|"computes scores"| node_metrics
node_metrics -->|"reports results"| node_user
node_evaluation -->|"uses paths"| node_config
node_user -->|"runs"| node_gradcam
node_gradcam -->|"loads test sample"| node_processed_data
node_gradcam -->|"loads best model"| node_model_store
node_gradcam -->|"generates overlay"| node_heatmap
node_gradcam -->|"uses paths"| node_config
node_heatmap -->|"displays visualization"| node_user

click node_dataset_job "https://github.com/watson752/ai_detection_model/blob/main/src/make_dataset.py"
click node_dicom_prep "https://github.com/watson752/ai_detection_model/blob/main/src/data_prep.py"
click node_config "https://github.com/watson752/ai_detection_model/blob/main/src/config.py"
click node_training "https://github.com/watson752/ai_detection_model/blob/main/src/train.py"
click node_cnn "https://github.com/watson752/ai_detection_model/blob/main/src/model.py"
click node_evaluation "https://github.com/watson752/ai_detection_model/blob/main/src/evaluate.py"
click node_metrics "https://github.com/watson752/ai_detection_model/blob/main/src/evaluate.py"
click node_gradcam "https://github.com/watson752/ai_detection_model/blob/main/src/grad_cam.py"
click node_heatmap "https://github.com/watson752/ai_detection_model/blob/main/src/grad_cam.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_dataset_job,node_dicom_prep,node_processed_data,node_user toneBlue
class node_training,node_cnn,node_model_store,node_raw_mri toneAmber
class node_evaluation,node_metrics,node_gradcam,node_heatmap toneMint
class node_config toneRose
```

## Components

### MRI preparation

- [Dataset builder](https://github.com/watson752/ai_detection_model/blob/main/src/make_dataset.py): `src/make_dataset.py`
- [DICOM preprocessing](https://github.com/watson752/ai_detection_model/blob/main/src/data_prep.py): `src/data_prep.py`
- **Processed arrays**

### Model training

- [Training workflow](https://github.com/watson752/ai_detection_model/blob/main/src/train.py): `src/train.py`
- [Binary CNN](https://github.com/watson752/ai_detection_model/blob/main/src/model.py): `src/model.py`
- **Saved models**

### Evaluation and interpretation

- [Test evaluation](https://github.com/watson752/ai_detection_model/blob/main/src/evaluate.py): `src/evaluate.py`
- [Classification metrics](https://github.com/watson752/ai_detection_model/blob/main/src/evaluate.py): `src/evaluate.py`
- [Grad-CAM visualization](https://github.com/watson752/ai_detection_model/blob/main/src/grad_cam.py): `src/grad_cam.py`
- [MRI heatmap overlay](https://github.com/watson752/ai_detection_model/blob/main/src/grad_cam.py): `src/grad_cam.py`

### Shared configuration

- [Path and image config](https://github.com/watson752/ai_detection_model/blob/main/src/config.py): `src/config.py`

### Other components

- **Dataset user**
- **Raw MRI data**

## Connections

- Dataset user → Raw MRI data: places scans (evidence: `README.md`)
- Dataset user → Dataset builder: runs (evidence: `README.md`)
- Dataset builder → DICOM preprocessing: builds classes (evidence: `src/make_dataset.py`)
- DICOM preprocessing → Raw MRI data: reads DICOM (evidence: `README.md`)
- Dataset builder → Processed arrays: writes arrays (evidence: `src/make_dataset.py`)
- Dataset builder → Path and image config: uses paths (evidence: `src/make_dataset.py`)
- DICOM preprocessing → Path and image config: uses image size (evidence: `src/data_prep.py`)
- Dataset user → Training workflow: runs (evidence: `README.md`)
- Training workflow → Processed arrays: loads arrays (evidence: `src/train.py`)
- Training workflow → Processed arrays: writes test split (evidence: `src/train.py`)
- Training workflow → Binary CNN: builds model (evidence: `src/train.py`)
- Training workflow → Saved models: saves checkpoints (evidence: `src/train.py`)
- Training workflow → Path and image config: uses paths (evidence: `src/train.py`)
- Binary CNN → Path and image config: uses dimensions (evidence: `src/model.py`)
- Dataset user → Test evaluation: runs (evidence: `README.md`)
- Test evaluation → Processed arrays: loads test data (evidence: `src/evaluate.py`)
- Test evaluation → Saved models: loads best model (evidence: `src/evaluate.py`)
- Test evaluation → Classification metrics: computes scores (evidence: `src/evaluate.py`)
- Classification metrics → Dataset user: reports results (evidence: `README.md`)
- Test evaluation → Path and image config: uses paths (evidence: `src/evaluate.py`)
- Dataset user → Grad-CAM visualization: runs (evidence: `README.md`)
- Grad-CAM visualization → Processed arrays: loads test sample (evidence: `src/grad_cam.py`)
- Grad-CAM visualization → Saved models: loads best model (evidence: `src/grad_cam.py`)
- Grad-CAM visualization → MRI heatmap overlay: generates overlay (evidence: `src/grad_cam.py`)
- Grad-CAM visualization → Path and image config: uses paths (evidence: `src/grad_cam.py`)
- MRI heatmap overlay → Dataset user: displays visualization (evidence: `src/grad_cam.py`)
