# zainkhatri/leukemia-classifier architecture

> Architecture diagram of the GitHub repository zainkhatri/leukemia-classifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zainkhatri/leukemia-classifier
- Repository: https://github.com/zainkhatri/leukemia-classifier

## Overview

##### Project Type & Purpose
- This is a research prototype/deep learning project for medical image classification. Its goal is to extract features from blood smear images using a CNN backbone (initially based on ResNet50 or EfficientNet variants, with attention mechanisms like CBAM), apply uncertainty quantification (via Monte Carlo Dropout and predictive entropy) and use custom preprocessing and augmentation techniques to reliably classify images as benign or as one of several malignant subtypes.
- Keep in mind that beyond the model’s core training/inference, you also have modules for data processing, training, evaluation, logging, visualization, and performance analysis.

##### Analyzing the File Structure
- Notice that most of the code resides in the “runs” folder. This contains key files such as:
– data_processing.py: Handles image ingestion, normalization, augmentation, and splitting.
– model.py and layers.py: Define the neural network architecture – the ResNet50 (or EfficientNet) backbone, CBAM layers, classification head, and uncertainty components.
– train.py, evaluate.py, predict.py: Essential for training the model, evaluating performance (with outputs like evaluation_metrics.json and training logs), and deploying inference respectively.
- Other files like the Proposal notebook and requirements.txt support project documentation and dependency management.

##### Model & System Components
a. Data Input & Processing:
b. Core Model Architecture:
- Under that, identify the “Attention Mechanism” (CBAM) and “Uncertainty Quantification Module” (Monte Carlo Dropout for confidence estimation) that enhance the overall model.
- Next, the “Classification Head” which entails global average pooling, dense layers, and softmax output.
c. Training and Ensemble Layers:
- A “Training Pipeline” component which connects the processed data to the model. Also indicate if there’s model ensemble logic (multiple models trained with different initializations) that aggregates predictions.
d. Evaluation & Visualization:

##### Relationships & Data Flow
- Dependency lines between modules (for example, data flows from processing to model, training logs are sent to evaluation, and evaluation results feed back into model tuning for hyperparameter optimization).

## Diagram (Mermaid)

```mermaid
graph TD
    RawImages["Raw Blood Smear Images"]:::input
    Preprocessing["Data Ingestion & Preprocessing"]:::processing
    Training["Training Pipeline"]:::model
    Inference["Inference/Predict Module"]:::inference
    Evaluation["Evaluation & Visualization"]:::evaluation
    EvalStorage["Evaluation Results Storage (logs,predictions,visualizations)"]:::evaluation
    Notebook["Exploratory Notebook"]:::documentation

    RawImages --> Preprocessing
    Preprocessing --> Training

    subgraph "Core Model Architecture"
        FE["Feature Extraction (ResNet50)"]:::model
        Attention["Attention Module (CBAM)"]:::model
        Uncertainty["Uncertainty Quantification (MC Dropout)"]:::model
        Classification["Classification Head"]:::model
        FE --> Attention
        Attention --> Uncertainty
        Uncertainty --> Classification
    end

    Training --> FE
    Classification --> Inference
    Classification --> Evaluation
    Evaluation --> EvalStorage
    EvalStorage -->|"feedback"| Training

    Notebook --- Training

    click Preprocessing "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/data_processing.py"
    click FE "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/model.py"
    click Attention "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/layers.py"
    click Uncertainty "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/layers.py"
    click Classification "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/layers.py"
    click Training "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/train.py"
    click Evaluation "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/evaluate.py"
    click EvalStorage "https://github.com/zainkhatri/leukemia-classifier/tree/main/runs/evaluation_results"
    click Inference "https://github.com/zainkhatri/leukemia-classifier/blob/main/runs/predict.py"
    click Notebook "https://github.com/zainkhatri/leukemia-classifier/blob/main/Proposal_Project_Wilson's All-Stars.ipynb"

    classDef input fill:#e0e0ff,stroke:#333,stroke-width:2px;
    classDef processing fill:#ccf,stroke:#333,stroke-width:2px;
    classDef model fill:#cfc,stroke:#333,stroke-width:2px;
    classDef evaluation fill:#ffc,stroke:#333,stroke-width:2px;
    classDef inference fill:#fcc,stroke:#333,stroke-width:2px;
    classDef documentation fill:#fc9,stroke:#333,stroke-width:2px;
```
