# lucasangio01/image-segmentation-unet architecture

> Architecture diagram of the GitHub repository lucasangio01/image-segmentation-unet, 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/lucasangio01/image-segmentation-unet
- Repository: https://github.com/lucasangio01/image-segmentation-unet

## Overview

##### Project type and purpose
- From the file tree and README, this is a Python‐based machine‐learning pipeline rather than a web service or UI. Its purpose is to compare several U-Net–style convolutional neural networks on a biomedical image segmentation task (knee ultrasound).

##### File structure
- Top‐level:
- Metrics/  → stores text files with performance metrics for each model/configuration
- code/     → the core Python modules (preprocessing, models, training, evaluation, utils)
- loss_results.txt → aggregated training/evaluation results
- pyproject.toml → dependency and packaging info
- Inside code/:
- preprocessing.py → data ingestion, augmentation, DataLoader setup
- utils.py         → helper functions and global variables
- models.py        → definitions of U-Net variants (UNet, UNet++, AttUNet)
- training.py      → training loop, checkpoint saving
- evaluation.py    → evaluation loop, mask prediction, metrics computation

##### README for additional insights
- Confirms ML pipeline steps: data loading → augmentation → model instantiation → train → evaluate → output metrics.
- No external services (databases or web APIs) are involved—everything runs locally on files.

##### Elements
- Clear labels: “Raw Images,” “Preprocessing,” “Models,” “Training,” “Evaluation,” “Metrics Storage,” “pyproject.toml”
→ from Raw Images to Preprocessing
→ from Preprocessing to Training (via DataLoader)
→ from Models to Training
→ from Training to Evaluation (via saved weights)
→ from Evaluation to Metrics Storage
- Rectangles for code modules (blue)
- Arrowheads to show the flow of data and dependencies

##### Detailed capture of essential architectural elements
- Don’t simply list all files; group them into logical components (e.g., all *.py under code/preprocessing.py into “Preprocessing Module”)
- Make explicit the imports between modules (e.g., Utils → all others)
- How Metrics/ and loss_results.txt form the output layer of the pipeline

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Data
    RawImages["Raw Ultrasound Images"]:::storage

    %% Code Modules
    Pre["Preprocessing Module"]:::code
    Models["Models Module"]:::code
    Training["Training Module"]:::code
    Evaluation["Evaluation Module"]:::code
    Utils["Utils Module"]:::code

    %% Storage Outputs
    LossResults[(loss_results.txt)]:::storage
    MetricsStorage[(Metrics Storage)]:::storage

    %% Configuration
    Config["pyproject.toml"]:::config
    Readme["README.md"]:::config

    %% Data Flow
    RawImages --> Pre
    Pre -->|"Augmented Data (DataLoader)"| Training
    Models --> Training
    Utils --> Pre
    Utils --> Models
    Utils --> Training
    Utils --> Evaluation
    Training -->|"Saves weights & loss"| LossResults
    LossResults --> Evaluation
    Models --> Evaluation
    Training --> Evaluation
    Evaluation -->|"Writes final metrics"| MetricsStorage

    %% Config Dependencies
    Config --> Pre
    Config --> Models
    Config --> Training
    Config --> Evaluation
    Readme --> Pre
    Readme --> Models
    Readme --> Training
    Readme --> Evaluation

    %% Click Events
    click Pre "https://github.com/lucasangio01/image-segmentation-unet/blob/main/code/preprocessing.py"
    click Models "https://github.com/lucasangio01/image-segmentation-unet/blob/main/code/models.py"
    click Training "https://github.com/lucasangio01/image-segmentation-unet/blob/main/code/training.py"
    click Evaluation "https://github.com/lucasangio01/image-segmentation-unet/blob/main/code/evaluation.py"
    click Utils "https://github.com/lucasangio01/image-segmentation-unet/blob/main/code/utils.py"
    click MetricsStorage "https://github.com/lucasangio01/image-segmentation-unet/tree/main/Metrics/"
    click LossResults "https://github.com/lucasangio01/image-segmentation-unet/blob/main/loss_results.txt"
    click Config "https://github.com/lucasangio01/image-segmentation-unet/blob/main/pyproject.toml"
    click Readme "https://github.com/lucasangio01/image-segmentation-unet/blob/main/README.md"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
