# huytrnq/deep-skin-lesion-classification architecture

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

- Interactive diagram: https://gitdiagram.com/huytrnq/deep-skin-lesion-classification
- Repository: https://github.com/huytrnq/deep-skin-lesion-classification

## Overview

##### Main Components
- Data Module:
- Data Sources: Represent the “datasets” directory that contains subfolders for Binary and Multiclass datasets, including accompanying text files (e.g., classes.txt, train.txt, test.txt, val.txt) and shell scripts (generate_data_files.sh).
- Data Preprocessing & Augmentation: Capture the functionality in the “utils/transform.py” and “utils/dataset.py” which likely handle geometric and contrast augmentations, noise introduction, etc.
- Model and Training Module:
- Model Architectures: Illustrate the “models” directory which contains implementations of EfficientNet (efficientnet.py), ResNet (resnet.py), Swin (swin.py) and custom loss functions (loss.py).
- Experiment Scripts: Include “exp.py” for single-run experiments and “exp_cv.py” for cross-validation runs.
- Ensemble: Highlight the standalone “ensemble.py” script which likely combines predictions from different models.
- Evaluation & Metrics:
- Testing Utilities: Include “test.py” and “test_cv.py” which handle the evaluation of the trained models.
- Metrics Calculation: Use “utils/metric.py” to show how the model performance (accuracy, kappa, etc.) is computed.
- Configuration & Dependency Management:
- Configuration: Represent “config.json” as a source of configurable parameters.
- Dependencies and Environment: Include “requirements.txt” and CI configuration in “.github/workflows” (such as the pylint workflow) for maintaining code quality.
- Monitoring & Logging:

##### Component Relationships & Data Flow
- Data Flow: Begin with the raw image data (from datasets) that is fed into the data preprocessing/augmentation layer.
- Model Training: Show that these experiments interact with the models (EfficientNet, ResNet, etc.) for training.
- Evaluation: Once models are trained, testing scripts (test.py, test_cv.py) and evaluation utilities (metrics) analyze model performance.
- Ensemble Process: The ensemble.py component may take predictions from different models as inputs to compute a final classifier output.

##### Architectural Patterns & Design Principles
- Modular Architecture: The project’s folder organization (separate directories for datasets, models, utils, etc.) encourages loose coupling. Each area (data, model, evaluation) is a self-contained module.
- Separation of Concerns: Distinct modules for configuration, data augmentation, model training, and evaluation ensure clarity in data flow and responsibilities.
- Experimentation & Reproducibility: The presence of separate experiment scripts (including those for cross-validation) and detailed configuration files shows an emphasis on reproducible research.
- CI/CD Integration: The GitHub workflows indicate adherence to quality and integration best practices.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Module
    subgraph "Data Module"
        DS["Data Sources"]:::data
        TForm["Transform (Data Augmentation)"]:::data
        DUtils["Dataset Utils"]:::data
    end
    DS -->|"raw_data"| TForm
    DS -->|"raw_data"| DUtils

    PD["Preprocessed Data"]:::data
    TForm -->|"augmented_data"| PD
    DUtils -->|"augmented_data"| PD

    %% Model & Training Module
    subgraph "Model & Training Module"
        ES1["Experiment Script (exp.py)"]:::training
        ES2["CV Experiment Script (exp_cv.py)"]:::training
        MA["Model Architectures"]:::training
        EN1["Ensemble Script"]:::training
        EN2["Ensemble Utils"]:::training
    end
    PD -->|"feeds"| ES1
    PD -->|"feeds"| ES2
    ES1 -->|"trains"| MA
    ES2 -->|"trains"| MA
    MA -->|"predictions"| EN1
    MA -->|"predictions"| EN2

    %% Evaluation & Metrics
    subgraph "Evaluation & Metrics"
        ET1["Testing (test.py)"]:::evaluation
        ET2["CV Testing (test_cv.py)"]:::evaluation
        MT["Metrics Calculation"]:::evaluation
    end
    MA -->|"trained_model"| ET1
    MA -->|"trained_model"| ET2
    EN1 -->|"ensemble_output"| ET1
    ET1 -->|"evaluates"| MT
    ET2 -->|"evaluates"| MT

    %% Monitoring & Logging
    LM["MLflow (Monitoring & Logging)"]:::external
    ES1 -->|"logs"| LM
    ES2 -->|"logs"| LM
    ET1 -->|"logs"| LM
    ET2 -->|"logs"| LM
    MT -->|"logs"| LM

    %% Configuration & Dependency Management
    subgraph "Configuration & Dependency"
        CFG["Configuration (config.json)"]:::configuration
        DEP["Dependencies (requirements.txt)"]:::configuration
        CI["CI Workflows"]:::configuration
    end
    CFG ---|"configures"| ES1
    CFG ---|"configures"| ES2
    DEP ---|"dependencies"| ES1
    DEP ---|"dependencies"| ES2
    CI ---|"quality_checks"| CFG

    %% Click Events
    click DS "https://github.com/huytrnq/deep-skin-lesion-classification/tree/main/datasets/"
    click TForm "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/utils/transform.py"
    click DUtils "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/utils/dataset.py"
    click MA "https://github.com/huytrnq/deep-skin-lesion-classification/tree/main/models/"
    click ES1 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/exp.py"
    click ES2 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/exp_cv.py"
    click EN1 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/ensemble.py"
    click EN2 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/utils/ensemble.py"
    click ET1 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/test.py"
    click ET2 "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/test_cv.py"
    click MT "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/utils/metric.py"
    click CFG "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/config.json"
    click DEP "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/requirements.txt"
    click CI "https://github.com/huytrnq/deep-skin-lesion-classification/blob/main/.github/workflows/pylint.yml"

    %% Styles
    classDef data fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef training fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef evaluation fill:#ffe082,stroke:#ff6f00,stroke-width:2px;
    classDef configuration fill:#d1c4e9,stroke:#4a148c,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
```
