# tirth27/skin-cancer-classification-using-deep-learning architecture

> Architecture diagram of the GitHub repository tirth27/skin-cancer-classification-using-deep-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tirth27/skin-cancer-classification-using-deep-learning
- Repository: https://github.com/tirth27/skin-cancer-classification-using-deep-learning

## Overview

##### Main system components
- Data Layer: This comprises the directories for both raw and processed data. Include components for “Raw CSV’s” (with subdirectories for 2018, 2019, and 2020), “Processed CSV’s” (the combined training/validation CSV files), “Augmented Sample Images,” and “Sample Images.” This layer represents your data ingestion and cleaning sources.
- Pre-processing & Data Augmentation Pipeline: Use the Notebooks (Data Preprocessing and Data Augmentation) and parts of the Src folder for data cleaning, cropping/resizing images, and applying augmentation transformations. Indicate components that deal with CSV updates for patient-level details and image cropping (e.g., 768x768 → 512x512 or similar).
- Model Training Pipeline: Represent the “Src/Model Training” folder which holds scripts like main_run.py, pre_train.py, and supporting modules (model_param.py, utils.py). This section should capture:
– Data loading from disk (reading images and CSVs).
– On-the-fly augmentation applied on the CPU.
– Forward pass through the CNN models (EfficientNet B4, B5, B7) on the GPU.
– Training loop with validation checkpoints and early stopping (as described in Figure 6 of the README).
– Logging and storing diagnostic/model logs.
– The ensemble mechanism where predictions are averaged.
- Model Optimization & Deployment: Include the conversion of raw models to the ONNX format for optimized serving. Show that the workflow first “trains model weights” then “converts to ONNX” (reducing weight size by 36%) before deployment.
- Inference and Web UI: Illustrate the web UI architecture as described in Figure 7 and subsequent figures. This component describes:
– Client-side: A GUI that includes patient detail form input (demographics) and image upload. Mention client-side validation (using JQuery) and the PDF report generation functionality.
– Server-side: The stateless inference service which receives validated data, loads the ONNX model, performs inference, and returns a JSON response with probability values for the nine target classes.
– The integration point between the user input and the deep learning model serving.

##### Inter-component relationships
- Data flows (CSV files, image files, logs) and model flows (training weights, ONNX conversion).

##### Important architectural patterns and design principles
- Separation of concerns: Distinction between data handling, model training, and the user interface.
- Hybrid compute usage: Explain that data augmentation is executed on the CPU, and the heavy CNN computation is performed on GPUs.
- Extensibility: Notate that additional configurations – as seen in Table 4 – could be added to the ensemble, indicating scalability.
- Interoperability: Emphasize the conversion to ONNX to support cross-hardware deployment in the production CAD system.

##### Relevant technologies and frameworks
- EfficientNet variants are the backbone of the CNN models.
- Onnx for model serving.
- Python notebooks (for EDA, preprocessing, augmentation).
- GitHub actions and issue templates as evidenced by the .github folder.
- Azure Compute/AKS for deployment (as mentioned for compute instance creation).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Layer
    subgraph "Data Layer"
        RawCSVs["Raw CSV's"]
        ProcessedCSVs["Processed CSV's"]
        AugImages["Augmented Sample Images"]
        SampleImages["Sample Images"]
    end

    %% Pre-processing & Data Augmentation Pipeline
    subgraph "Pre-processing & Augmentation"
        DataPrep["Data Preprocessing"]
        DataAug["Data Augmentation"]
        EDA["Exploratory Data Analysis"]
    end

    %% Model Training Pipeline
    subgraph "Model Training Pipeline"
        MainScript["Main Training Script"]
        PreTrain["Pre-train Module"]
        ModelParam["Model Parameters"]
        Utils["Utility Functions"]
        DataLoading["Data Loading & On-the-fly Augmentation"]
        ForwardPass["CNN Forward Pass (EfficientNet Ensemble)"]
        TrainingLoop["Training Loop with Validation"]
        ModelLogs["Logging & Checkpoints"]
        ConsoleLogs["Console Logs"]
        PredictionLogs["Prediction Logs"]
    end

    %% Model Optimization & Deployment
    subgraph "Model Optimization & Deployment"
        ONNX["ONNX Conversion"]
        Deployment["Model Deployment"]
    end

    %% Inference & Web UI
    subgraph "Inference & Web UI"
        WebUI["Web UI Client (Patient Form & Image Upload)"]
        ClientValidation["Client-side Validation (JQuery)"]
        InferenceAPI["Inference API (ONNX-Based)"]
        ModelPrediction["Model Prediction"]
        JSONResponse["JSON Response"]
        PDFReport["PDF Report Generator"]
    end

    %% Data Flow from Data Layer to Pre-processing
    RawCSVs -->|"feeds"| DataPrep
    SampleImages -->|"feeds"| DataPrep
    ProcessedCSVs -- "optional input" --> DataPrep
    AugImages -- "optional input" --> DataPrep

    %% Pre-processing pipeline flow
    DataPrep -->|"cleaned data"| DataAug
    DataPrep -->|"insights"| EDA
    DataAug -->|"augmented data"| DataLoading

    %% Model Training Pipeline Assembly
    MainScript -->|"triggers"| DataLoading
    PreTrain -->|"supports"| DataLoading
    ModelParam -->|"configures"| DataLoading
    Utils -->|"assists"| DataLoading
    DataLoading -->|"forward pass"| ForwardPass
    ForwardPass -->|"training operations"| TrainingLoop
    TrainingLoop -->|"logs updates"| ModelLogs
    ModelLogs -->|"detailed logs"| ConsoleLogs
    ModelLogs -->|"prediction outputs"| PredictionLogs

    %% Transition to Model Optimization & Deployment
    ModelLogs -->|"trained weights"| ONNX
    ONNX -->|"optimized model"| Deployment

    %% Inference & Web UI Flow
    WebUI -->|"user input"| ClientValidation
    ClientValidation -->|"API call"| InferenceAPI
    Deployment -->|"loads ONNX model"| InferenceAPI
    InferenceAPI -->|"predicts"| ModelPrediction
    ModelPrediction -->|"returns"| JSONResponse
    JSONResponse -->|"updates UI"| WebUI
    WebUI -->|"generates"| PDFReport

    %% Styling classes
    classDef data fill:#AEDFF7,stroke:#006699,stroke-width:2px;
    classDef preprocess fill:#C3F0CA,stroke:#2E8B57,stroke-width:2px;
    classDef training fill:#F7C6C7,stroke:#CC0033,stroke-width:2px;
    classDef deployment fill:#FFF2B2,stroke:#E6A800,stroke-width:2px;
    classDef webui fill:#D9B3FF,stroke:#8A2BE2,stroke-width:2px;

    %% Assign classes to Data Layer nodes
    class RawCSVs,ProcessedCSVs,AugImages,SampleImages data;
    %% Assign classes to Pre-processing nodes
    class DataPrep,DataAug,EDA preprocess;
    %% Assign classes to Model Training nodes
    class MainScript,PreTrain,ModelParam,Utils,DataLoading,ForwardPass,TrainingLoop,ModelLogs,ConsoleLogs,PredictionLogs training;
    %% Assign classes to Model Optimization nodes
    class ONNX,Deployment deployment;
    %% Assign classes to Inference & Web UI nodes
    class WebUI,ClientValidation,InferenceAPI,ModelPrediction,JSONResponse,PDFReport webui;

    %% Click Events for Data Layer
    click RawCSVs "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Data/Raw CSV's"
    click ProcessedCSVs "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Data/Processed CSV's"
    click AugImages "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Data/Augmented Sample Images"
    click SampleImages "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Data/Sample Images"

    %% Click Events for Pre-processing & Data Augmentation Pipeline
    click DataPrep "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Notebooks/Data Preprocessing.ipynb"
    click DataAug "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Notebooks/Data Augumentation.ipynb"
    click EDA "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Notebooks/Exploratory Data Analysis.ipynb"

    %% Click Events for Model Training Pipeline
    click MainScript "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Src/Model Training/main_run.py"
    click PreTrain "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Src/Model Training/pre_train.py"
    click ModelParam "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Src/Model Training/model_param.py"
    click Utils "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/blob/main/Src/Model Training/utils.py"
    click ModelLogs "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Src/Model Training/Model Logs"
    click ConsoleLogs "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Src/Model Training/Model Logs/consoleLogs"
    click PredictionLogs "https://github.com/tirth27/skin-cancer-classification-using-deep-learning/tree/main/Src/Model Training/Model Logs/prediction"
```
