# ai-med-agh/cnn-classifier architecture

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

- Interactive diagram: https://gitdiagram.com/ai-med-agh/cnn-classifier
- Repository: https://github.com/ai-med-agh/cnn-classifier

## Overview

This repository is a configurable PyTorch CNN project for multiclass heart-disease image classification. Its main workflow prepares and splits labeled images, loads and augments training and validation data, trains and evaluates a model, then writes checkpoints and training logs/plots. Configuration and evaluation are separate supporting concerns. The README documents a test split, but the sampled loader uses only train and validation; prediction appears incomplete in the excerpt. Edges reflect the excerpts, SOURCE INDEX references, or README; unsampled behavior is not assumed.

Main entry points: [`TrainingManager.py`](https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py) (Training manager), [`dataset_manager/dataset_manager.py`](https://github.com/ai-med-agh/cnn-classifier/blob/main/dataset_manager/dataset_manager.py) (Dataset and loaders), [`config.py`](https://github.com/ai-med-agh/cnn-classifier/blob/main/config.py) (Project configuration), [`preprocessing.py`](https://github.com/ai-med-agh/cnn-classifier/blob/main/preprocessing.py) (Image preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_preprocessing["Image preprocessing<br/>[preprocessing.py]"]
  node_prepared_data[("Prepared image splits")]
  node_data_loader["Dataset and loaders<br/>[dataset_manager.py]"]
  node_transforms["Image transforms<br/>[transform.py]"]
end

subgraph group_runtime["Training runtime"]
  node_train_cli["Training entry point<br/>[train.py]"]
  node_trainer["Training manager<br/>[TrainingManager.py]"]
  node_model["CNN model<br/>[TrainingManager.py]"]
  node_validation["Validation metrics<br/>[TrainingManager.py]"]
  node_checkpoint_store[("Model checkpoints")]
  node_logger["Training logger<br/>[logger.py]"]
  node_training_logs["Logs and plots"]
  node_prediction["Prediction module<br/>[predict.py]"]
end

subgraph group_support["Configuration and metrics"]
  node_config["Project configuration<br/>[config.py]"]
  node_evaluation["Precision and recall<br/>[evaluation.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"runs preprocessing"| node_preprocessing
node_preprocessing -->|"reads settings"| node_config
node_preprocessing -->|"creates splits"| node_prepared_data
node_researcher -->|"starts training"| node_train_cli
node_train_cli -->|"creates and runs"| node_trainer
node_trainer -->|"reads settings"| node_config
node_trainer -->|"requests loaders"| node_data_loader
node_data_loader -->|"reads settings"| node_config
node_data_loader -->|"reads train and val"| node_prepared_data
node_data_loader -->|"applies transforms"| node_transforms
node_trainer -->|"trains model"| node_model
node_trainer -->|"evaluates model"| node_validation
node_trainer -->|"saves and loads"| node_checkpoint_store
node_trainer -->|"records metrics"| node_logger
node_logger -->|"reads log path"| node_config
node_logger -->|"writes logs and plots"| node_training_logs

click node_preprocessing "https://github.com/ai-med-agh/cnn-classifier/blob/main/preprocessing.py"
click node_data_loader "https://github.com/ai-med-agh/cnn-classifier/blob/main/dataset_manager/dataset_manager.py"
click node_transforms "https://github.com/ai-med-agh/cnn-classifier/blob/main/augmentation/transform.py"
click node_config "https://github.com/ai-med-agh/cnn-classifier/blob/main/config.py"
click node_train_cli "https://github.com/ai-med-agh/cnn-classifier/blob/main/train.py"
click node_trainer "https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py"
click node_model "https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py"
click node_validation "https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py"
click node_logger "https://github.com/ai-med-agh/cnn-classifier/blob/main/logger.py"
click node_evaluation "https://github.com/ai-med-agh/cnn-classifier/blob/main/evaluation.py"
click node_prediction "https://github.com/ai-med-agh/cnn-classifier/blob/main/predict.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_preprocessing,node_prepared_data,node_data_loader,node_transforms toneBlue
class node_train_cli,node_trainer,node_model,node_validation,node_checkpoint_store,node_logger,node_training_logs,node_prediction toneAmber
class node_config,node_evaluation toneMint
class node_researcher toneIndigo
```

## Components

### Data preparation

- [Image preprocessing](https://github.com/ai-med-agh/cnn-classifier/blob/main/preprocessing.py): `preprocessing.py`
- **Prepared image splits**
- [Dataset and loaders](https://github.com/ai-med-agh/cnn-classifier/blob/main/dataset_manager/dataset_manager.py): `dataset_manager/dataset_manager.py`
- [Image transforms](https://github.com/ai-med-agh/cnn-classifier/blob/main/augmentation/transform.py): `augmentation/transform.py`

### Training runtime

- [Training entry point](https://github.com/ai-med-agh/cnn-classifier/blob/main/train.py): `train.py`
- [Training manager](https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py): `TrainingManager.py`
- [CNN model](https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py): `TrainingManager.py`
- [Validation metrics](https://github.com/ai-med-agh/cnn-classifier/blob/main/TrainingManager.py): `TrainingManager.py`
- **Model checkpoints**
- [Training logger](https://github.com/ai-med-agh/cnn-classifier/blob/main/logger.py): `logger.py`
- **Logs and plots**
- [Prediction module](https://github.com/ai-med-agh/cnn-classifier/blob/main/predict.py): `predict.py`

### Configuration and metrics

- [Project configuration](https://github.com/ai-med-agh/cnn-classifier/blob/main/config.py): `config.py`
- [Precision and recall](https://github.com/ai-med-agh/cnn-classifier/blob/main/evaluation.py): `evaluation.py`

### Other components

- **Researcher**

## Connections

- Researcher → Image preprocessing: runs preprocessing (evidence: `README.md`)
- Image preprocessing → Project configuration: reads settings (evidence: `preprocessing.py`)
- Image preprocessing → Prepared image splits: creates splits (evidence: `preprocessing.py`)
- Researcher → Training entry point: starts training (evidence: `README.md`)
- Training entry point → Training manager: creates and runs (evidence: `train.py`)
- Training manager → Project configuration: reads settings (evidence: `TrainingManager.py`)
- Training manager → Dataset and loaders: requests loaders (evidence: `TrainingManager.py`)
- Dataset and loaders → Project configuration: reads settings (evidence: `dataset_manager/dataset_manager.py`)
- Dataset and loaders → Prepared image splits: reads train and val (evidence: `dataset_manager/dataset_manager.py`)
- Dataset and loaders → Image transforms: applies transforms (evidence: `dataset_manager/dataset_manager.py`)
- Training manager → CNN model: trains model (evidence: `TrainingManager.py`)
- Training manager → Validation metrics: evaluates model (evidence: `TrainingManager.py`)
- Training manager → Model checkpoints: saves and loads (evidence: `TrainingManager.py`)
- Training manager → Training logger: records metrics (evidence: `TrainingManager.py`)
- Training logger → Project configuration: reads log path (evidence: `logger.py`)
- Training logger → Logs and plots: writes logs and plots (evidence: `logger.py`)
