# runner-xc/rdamu-net architecture

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

- Interactive diagram: https://gitdiagram.com/runner-xc/rdamu-net
- Repository: https://github.com/runner-xc/rdamu-net

## Overview

##### Project type and purpose
- This is a research-oriented deep-learning image segmentation toolkit focused on shale microstructure segmentation. It provides multiple U-Net-style and related architectures (including the novel RDAMU-Net), end-to-end training, evaluation, logging, and slide-based prediction pipelines.

##### File structure
- Top-level “train.py” and “predict.py” scripts: entry points for training and inference.
- “model/”: definitions of all segmentation networks (SegNet, U-Net variants, DeepLabV3, PSPNet, RDAMU-Net).
- “model/utils/”: building-block modules (attention, backbones, utility layers).
- “utils/”: data preparation, augmentation (“transforms.py”), dataset splitting, custom losses, metrics, logging, TensorBoard integration, experiment-management helpers, slide-based inference.
- “cam.py”: class-activation mapping for model interpretability.
- Shell script “train_models.sh” for batch training.

##### Key insights from README
- Project is invoked via CLI arguments to “train.py” (data paths, model choice).
- Data structure: raw images + masks + CSV index files.
- Core contribution is the RDAMU-Net architecture, combining dilated residuals, multi-scale fusion, and multi-dimensional attention.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources
    subgraph "Data Sources"
        DS1["Raw SEM Images"]:::data
        DS2["Raw Masks"]:::data
        DS3["CSV Indices"]:::data
    end

    %% Data Preparation & Loading
    subgraph "Data Prep & Loading"
        T["Transforms & Augmentations"]:::process
        D["Dataset & DataLoader"]:::process
    end

    %% Model Zoo
    subgraph "Model Zoo" 
        MN1["SegNet"]:::model
        MN2["U-Net"]:::model
        MN3["a_U-Net"]:::model
        MN4["m_U-Net"]:::model
        MN5["U2-Net"]:::model
        MN6["DeepLabV3"]:::model
        MN7["PSPNet"]:::model
        MN8["RDAMU-Net"]:::model
    end

    %% Model Building Blocks
    subgraph "Building Blocks"
        MB1["Attention Modules"]:::model
        MB2["ResNet Backbone"]:::model
        MB3["MobileNet Backbone"]:::model
        MB4["Utility Layers"]:::model
    end

    %% Training Pipeline
    subgraph "Training Pipeline"
        TP1["train.py"]:::process
        TP2["Train & Eval Orchestration"]:::process
        TP3["Model Init & Params"]:::process
        TP4["Loss Functions"]:::process
        TP5["Metrics Computation"]:::process
        TP6["Logging & TensorBoard"]:::external
        TP7["Checkpoint Storage"]:::external
    end

    %% Prediction Pipeline
    subgraph "Prediction Pipeline"
        PP1["predict.py"]:::process
        PP2["Slide Predict"]:::process
        PP3["Mask to Int Conversion"]:::process
        PP4["Inference Log Writer"]:::external
    end

    %% Interpretability
    CAM["cam.py (CAM Utility)"]:::process

    %% Experiment Management
    subgraph "Experiment Management"
        EM1["Batch Training Script"]:::external
        EM2["TensorBoard Server"]:::external
        EM3["Experiment Log Writer"]:::external
    end

    %% Connections
    DS1 --> T
    DS2 --> T
    DS3 --> T
    T --> D

    D --> TP1
    TP1 --> TP2
    TP2 --> MN1
    TP2 --> MN2
    TP2 --> MN3
    TP2 --> MN4
    TP2 --> MN5
    TP2 --> MN6
    TP2 --> MN7
    TP2 --> MN8
    TP2 --> MB1
    TP2 --> MB2
    TP2 --> MB3
    TP2 --> MB4
    MN1 --> TP4
    MN2 --> TP4
    MN3 --> TP4
    MN4 --> TP4
    MN5 --> TP4
    MN6 --> TP4
    MN7 --> TP4
    MN8 --> TP4
    MB1 --> MN8
    MB2 --> MN8
    MB3 --> MN8
    MB4 --> MN8

    TP4 --> TP5
    TP5 --> TP6
    TP6 --> TP7

    TP7 -.-> PP1

    PP1 --> T
    PP1 --> PP2
    PP2 --> PP3
    PP3 --> PP4

    MN1 --> CAM
    MN2 --> CAM
    MN3 --> CAM
    MN4 --> CAM
    MN5 --> CAM
    MN6 --> CAM
    MN7 --> CAM
    MN8 --> CAM

    EM1 --> TP1
    EM2 --> TP6
    EM3 --> PP4

    %% Click Events
    click DS1 "https://github.com/runner-xc/rdamu-net/tree/main/images/"
    click DS3 "https://github.com/runner-xc/rdamu-net/blob/main/utils/data_split.py"
    click T "https://github.com/runner-xc/rdamu-net/blob/main/utils/transforms.py"
    click D "https://github.com/runner-xc/rdamu-net/blob/main/utils/my_data.py"
    click MN1 "https://github.com/runner-xc/rdamu-net/blob/main/model/Segnet.py"
    click MN2 "https://github.com/runner-xc/rdamu-net/blob/main/model/unet.py"
    click MN3 "https://github.com/runner-xc/rdamu-net/blob/main/model/a_unet.py"
    click MN4 "https://github.com/runner-xc/rdamu-net/blob/main/model/m_unet.py"
    click MN5 "https://github.com/runner-xc/rdamu-net/blob/main/model/u2net.py"
    click MN6 "https://github.com/runner-xc/rdamu-net/blob/main/model/deeplabv3.py"
    click MN7 "https://github.com/runner-xc/rdamu-net/blob/main/model/pspnet.py"
    click MN8 "https://github.com/runner-xc/rdamu-net/blob/main/model/rdam_unet.py"
    click MB1 "https://github.com/runner-xc/rdamu-net/blob/main/model/utils/attention.py"
    click MB2 "https://github.com/runner-xc/rdamu-net/blob/main/model/utils/resnet_backbone.py"
    click MB3 "https://github.com/runner-xc/rdamu-net/blob/main/model/utils/mobilenet_backbone.py"
    click MB4 "https://github.com/runner-xc/rdamu-net/blob/main/model/utils/modules.py"
    click TP1 "https://github.com/runner-xc/rdamu-net/blob/main/train.py"
    click TP2 "https://github.com/runner-xc/rdamu-net/blob/main/utils/train_and_eval.py"
    click TP3 "https://github.com/runner-xc/rdamu-net/blob/main/utils/model_initial.py"
    click TP4 "https://github.com/runner-xc/rdamu-net/blob/main/utils/loss_fn.py"
    click TP5 "https://github.com/runner-xc/rdamu-net/blob/main/utils/metrics.py"
    click TP6 "https://github.com/runner-xc/rdamu-net/blob/main/utils/writing_logs.py"
    click EM2 "https://github.com/runner-xc/rdamu-net/blob/main/utils/run_tensorboard.py"
    click PP1 "https://github.com/runner-xc/rdamu-net/blob/main/predict.py"
    click PP2 "https://github.com/runner-xc/rdamu-net/blob/main/utils/slide_predict.py"
    click PP3 "https://github.com/runner-xc/rdamu-net/blob/main/utils/mask_to_int.py"
    click PP4 "https://github.com/runner-xc/rdamu-net/blob/main/utils/write_experiment_log.py"
    click EM1 "https://github.com/runner-xc/rdamu-net/blob/main/train_models.sh"
    click CAM "https://github.com/runner-xc/rdamu-net/blob/main/cam.py"

    %% Styles
    classDef data fill:#bbddff,stroke:#0077cc,color:#000;
    classDef process fill:#ffee99,stroke:#cc9900,color:#000;
    classDef model fill:#ccffcc,stroke:#00aa00,color:#000;
    classDef external fill:#ffcc99,stroke:#cc6600,color:#000;
```
