# anashxh/dm-ahr architecture

> Architecture diagram of the GitHub repository anashxh/dm-ahr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anashxh/dm-ahr
- Repository: https://github.com/anashxh/dm-ahr

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Data Processing Layer:
- Input Pipeline (/data directory)
- Dataset Handling (LRHR_dataset.py)
- Data Preparation (prepare_data.py)

b) Model Architecture:
- Core Diffusion Model Components
- SR3 Modules (sr3_modules/)
- DDPM Modules (ddpm_modules/)
- Base Model Framework (base_model.py)
- Network Implementations (networks.py)

c) Configuration System:
- Multiple JSON configs for different skin conditions
- Configuration Management System

d) Execution Pipeline:
- Training Pipeline
- Inference Pipeline (infer.py)
- Evaluation System (eval.py)

##### Component Relationships

**[Input Images] → [Data Processing] → [Diffusion Model] → [Hair Removal Output]**
- ↓
- [Evaluation Metrics]

##### Detailed Architecture Elements

- Data Pipeline     |

- LRHR Dataset        |
- Data Preparation    |
- Data Utilities      |

- ↓

- Diffusion Model    |

- UNet Architecture   |
- Diffusion Process   |
- SR3 Modules         |

- ↓

- Evaluation System    |

- Metrics             |
- Logger              |
- WandB Integration   |

##### Technical Details

- Input/Output specifications
- Resolution handling (16→128 as seen in dataset name)
- Configuration flow from JSON files
- Metrics collection points

##### Implementation Notes

- The iterative refinement process (based on SR3)
- The specialized handling of dermoscopic images
- The configuration system for different skin conditions
- The evaluation and metrics collection system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Data_Processing
        Input[Input Images]
        DataPrep["Data Preparation"]:::data
        DataUtil["Data Utilities"]:::data
        Dataset["LRHR Dataset"]:::data
    end

    subgraph Model_Architecture
        DiffModel["Diffusion Model"]
        
        subgraph SR3_Components
            SR3Diff["SR3 Diffusion"]:::model
            SR3UNet["SR3 UNet"]:::model
        end
        
        subgraph DDPM_Components
            DDPMDiff["DDPM Diffusion"]:::model
            DDPMUNet["DDPM UNet"]:::model
        end
        
        BaseModel["Base Model"]:::model
        Networks["Network Implementation"]:::model
    end

    subgraph Config_System
        Config["Configuration Management"]:::config
    end

    subgraph Execution_Pipeline
        Training["Training Pipeline"]
        Inference["Inference System"]:::exec
        Eval["Evaluation System"]:::exec
    end

    subgraph Logging_Metrics
        Logger["Logging System"]:::logging
        WandB["WandB Integration"]:::logging
        Metrics["Metrics Collection"]:::logging
    end

    %% Data Flow
    Input --> DataPrep
    DataPrep --> Dataset
    DataUtil --> Dataset
    Dataset --> DiffModel
    
    %% Model Components
    DiffModel --> SR3_Components
    DiffModel --> DDPM_Components
    SR3Diff --> SR3UNet
    DDPMDiff --> DDPMUNet
    BaseModel --> Networks
    Networks --> DiffModel
    
    %% Config and Execution
    Config --> Training
    Config --> Inference
    DiffModel --> Training
    DiffModel --> Inference
    Training --> Eval
    Inference --> Eval
    
    %% Logging and Metrics
    Eval --> Logger
    Logger --> WandB
    Metrics --> Eval

    %% Click Events
    click DataPrep "https://github.com/AnasHXH/DM-AHR/blob/main/data/prepare_data.py"
    click DataUtil "https://github.com/AnasHXH/DM-AHR/blob/main/data/util.py"
    click Dataset "https://github.com/AnasHXH/DM-AHR/blob/main/data/LRHR_dataset.py"
    click SR3Diff "https://github.com/AnasHXH/DM-AHR/blob/main/model/sr3_modules/diffusion.py"
    click SR3UNet "https://github.com/AnasHXH/DM-AHR/blob/main/model/sr3_modules/unet.py"
    click DDPMDiff "https://github.com/AnasHXH/DM-AHR/blob/main/model/ddpm_modules/diffusion.py"
    click DDPMUNet "https://github.com/AnasHXH/DM-AHR/blob/main/model/ddpm_modules/unet.py"
    click BaseModel "https://github.com/AnasHXH/DM-AHR/blob/main/model/base_model.py"
    click Networks "https://github.com/AnasHXH/DM-AHR/blob/main/model/networks.py"
    click Config "https://github.com/AnasHXH/DM-AHR/tree/main/config/"
    click Inference "https://github.com/AnasHXH/DM-AHR/blob/main/infer.py"
    click Eval "https://github.com/AnasHXH/DM-AHR/blob/main/eval.py"
    click Logger "https://github.com/AnasHXH/DM-AHR/blob/main/core/logger.py"
    click WandB "https://github.com/AnasHXH/DM-AHR/blob/main/core/wandb_logger.py"
    click Metrics "https://github.com/AnasHXH/DM-AHR/blob/main/core/metrics.py"

    %% Styling
    classDef data fill:#3498db
    classDef model fill:#2ecc71
    classDef config fill:#f1c40f
    classDef exec fill:#e74c3c
    classDef logging fill:#9b59b6

    %% Legend
    subgraph Legend
        L1[Data Components]:::data
        L2[Model Components]:::model
        L3[Config Components]:::config
        L4[Execution Components]:::exec
        L5[Logging Components]:::logging
    end
```
