# conn-finnegan/soma_skin_cancer architecture

> Architecture diagram of the GitHub repository conn-finnegan/soma_skin_cancer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/conn-finnegan/soma_skin_cancer
- Repository: https://github.com/conn-finnegan/soma_skin_cancer

## Overview

##### Project type and purpose
- This is a privacy-focused AI/ML pipeline tool for classifying dermoscopic skin-lesion images as benign or malignant.
- It provides:
- Model training (PyTorch + ResNet-18)
- Model evaluation
- Inference (single / batch image prediction + Grad-CAM overlays)
- A CLI-style usage pattern (no images are stored or logged).

##### File structure
Root files:
- README.md – project overview and usage
- requirements.txt – Python dependencies (PyTorch, torchvision, Grad-CAM libs)
- Lumen_Skin_Cancer.code-workspace – VS Code workspace config
models/
- skin_cancer_resnet18_v1.mlmodel (to be deprecated – drop this once iOS feature is removed)
src/
- load_data.py – data ingestion/preprocessing
- dataset.py – dataset wrapper for HAM10000
- train_model.py – training script (fine-tunes ResNet-18)
- evaluate.py – runs evaluation on a held-out set
- predict_image.py – single-image inference + Grad-CAM
- test_loader.py – sanity checks on data loaders

##### README for additional insights
- Emphasises “all inference runs in-memory; no images stored.”
- Deployment target: Hugging Face Spaces (Gradio) – not part of this file tree, but consider as an external demo UI.

[ ] Lay out the seven components listed in 4a
[ ] Encapsulate any external demo or integration as a separate module

## Diagram (Mermaid)

```mermaid
graph TD
    %% Configuration & Dependencies
    Readme["README.md"]:::config
    Req["requirements.txt"]:::config

    %% Data Source
    DataSource["External HAM10000 Dataset"]:::data

    %% Data Preprocessing & Loader
    subgraph "Data Preprocessing & Loader"
        LoadData["load_data.py"]:::compute
        Dataset["dataset.py"]:::compute
    end

    %% Training Engine
    Train["train_model.py"]:::compute

    %% Model Artifact Store
    ModelStore["Model Artifact Store"]:::storage

    %% Evaluation Engine
    Eval["evaluate.py"]:::compute

    %% Optional Deployment
    subgraph "Optional Deployment"
        Inf["predict_image.py"]:::compute
        DemoUI["Hugging Face Spaces / Gradio"]:::external
    end

    %% Privacy Note
    Note["All processing in-memory; no images stored"]:::note

    %% Data Flow
    DataSource -->|"images → tensors"| LoadData
    LoadData -->|"preprocessed tensors"| Dataset
    Dataset -->|"training data"| Train
    Train -->|"trained model (.pt)"| ModelStore
    ModelStore -->|"model loaded"| Eval
    Eval -->|"evaluation metrics"| Note
    ModelStore -->|"model.pt → inference"| Inf
    Inf -->|"prediction + Grad-CAM"| Note
    Inf <-->|"inference calls"| DemoUI

    %% Click Events
    click LoadData "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/src/load_data.py"
    click Dataset "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/src/dataset.py"
    click Train "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/src/train_model.py"
    click ModelStore "https://github.com/conn-finnegan/soma_skin_cancer/tree/main/models/"
    click Eval "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/src/evaluate.py"
    click Inf "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/src/predict_image.py"
    click Readme "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/README.md"
    click Req "https://github.com/conn-finnegan/soma_skin_cancer/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#cfe2f3,stroke:#2b60a7,color:#0b2e4b;
    classDef compute fill:#d9ead3,stroke:#6aa84f,color:#274e13;
    classDef storage fill:#fce5cd,stroke:#e69138,color:#7f6000;
    classDef external fill:#e0e0e0,stroke:#666666,color:#333333;
    classDef config fill:#f4cccc,stroke:#cc0000,color:#660000;
    classDef note fill:#eeeeee,stroke:#888888,color:#444444,stroke-dasharray: 2 2;
```
