# saifullah-s/pneumonia-detection architecture

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

- Interactive diagram: https://gitdiagram.com/saifullah-s/pneumonia-detection
- Repository: https://github.com/saifullah-s/pneumonia-detection

## Overview

PneumoCatcher is a chest-X-ray pneumonia classification project. Its documented workflow preprocesses labeled images, trains and compares a custom CNN with fine-tuned ResNet-50 variants, evaluates their predictions, and uses Grad-CAM to explain model decisions. The JPEG-to-HDF5 converter is directly evidenced in source; the notebook’s model and analysis stages are represented from README descriptions because its contents were not sampled. The README also describes reporting and presentation deliverables, which are not runtime components.

Main entry points: [`pneumonia_detection.ipynb`](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb) (Pneumonia predictions), [`data/jpeg_to_hdf5.py`](https://github.com/saifullah-s/pneumonia-detection/blob/main/data/jpeg_to_hdf5.py) (JPEG converter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Image preparation"]
  node_converter["JPEG converter<br/>[jpeg_to_hdf5.py]"]
  node_hdf5[("HDF5 image set")]
  node_preprocessing["Image preprocessing"]
  node_split["Train/test split"]
end

subgraph group_modeling["Modeling"]
  node_custom_cnn["Custom CNN"]
  node_resnet["Fine-tuned ResNet-50"]
  node_predictions["Pneumonia predictions"]
end

subgraph group_analysis["Evaluation and interpretation"]
  node_evaluation["Model evaluation"]
  node_gradcam["Grad-CAM heatmaps"]
  node_findings["Results and recommendations"]
end

node_researcher(("Researcher"))
node_xray_data[("Labeled X-rays")]

node_researcher -->|"prepares data"| node_converter
node_xray_data -->|"reads JPEGs"| node_converter
node_converter -->|"writes images"| node_hdf5
node_hdf5 -->|"converts to arrays"| node_preprocessing
node_preprocessing -->|"prepares split"| node_split
node_researcher -->|"runs analysis"| node_preprocessing
node_split -->|"trains"| node_custom_cnn
node_split -->|"fine-tunes"| node_resnet
node_custom_cnn -->|"classifies"| node_predictions
node_resnet -->|"classifies"| node_predictions
node_predictions -->|"evaluates metrics"| node_evaluation
node_predictions -->|"generates heatmaps"| node_gradcam
node_evaluation -->|"informs findings"| node_findings
node_gradcam -->|"informs findings"| node_findings
node_findings -->|"reports results"| node_researcher

click node_converter "https://github.com/saifullah-s/pneumonia-detection/blob/main/data/jpeg_to_hdf5.py"
click node_preprocessing "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_split "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_custom_cnn "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_resnet "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_predictions "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_evaluation "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_gradcam "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"
click node_findings "https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb"

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_converter,node_hdf5,node_preprocessing,node_split toneBlue
class node_custom_cnn,node_resnet,node_predictions,node_xray_data toneAmber
class node_evaluation,node_gradcam,node_findings toneMint
class node_researcher toneIndigo
```

## Components

### Image preparation

- [JPEG converter](https://github.com/saifullah-s/pneumonia-detection/blob/main/data/jpeg_to_hdf5.py): `data/jpeg_to_hdf5.py`
- **HDF5 image set**
- [Image preprocessing](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`
- [Train/test split](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`

### Modeling

- [Custom CNN](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`
- [Fine-tuned ResNet-50](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`
- [Pneumonia predictions](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`

### Evaluation and interpretation

- [Model evaluation](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`
- [Grad-CAM heatmaps](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`
- [Results and recommendations](https://github.com/saifullah-s/pneumonia-detection/blob/main/pneumonia_detection.ipynb): `pneumonia_detection.ipynb`

### Other components

- **Researcher**
- **Labeled X-rays**

## Connections

- Researcher → JPEG converter: prepares data (evidence: `README.md`)
- Labeled X-rays → JPEG converter: reads JPEGs (evidence: `data/jpeg_to_hdf5.py`)
- JPEG converter → HDF5 image set: writes images (evidence: `data/jpeg_to_hdf5.py`)
- HDF5 image set → Image preprocessing: converts to arrays (evidence: `README.md`)
- Image preprocessing → Train/test split: prepares split (evidence: `README.md`)
- Researcher → Image preprocessing: runs analysis (evidence: `README.md`)
- Train/test split → Custom CNN: trains (evidence: `README.md`)
- Train/test split → Fine-tuned ResNet-50: fine-tunes (evidence: `README.md`)
- Custom CNN → Pneumonia predictions: classifies (evidence: `README.md`)
- Fine-tuned ResNet-50 → Pneumonia predictions: classifies (evidence: `README.md`)
- Pneumonia predictions → Model evaluation: evaluates metrics (evidence: `README.md`)
- Pneumonia predictions → Grad-CAM heatmaps: generates heatmaps (evidence: `README.md`)
- Model evaluation → Results and recommendations: informs findings (evidence: `README.md`)
- Grad-CAM heatmaps → Results and recommendations: informs findings (evidence: `README.md`)
- Results and recommendations → Researcher: reports results (evidence: `README.md`)
