# boyuanjiang/fitdit architecture

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

- Interactive diagram: https://gitdiagram.com/boyuanjiang/fitdit
- Repository: https://github.com/boyuanjiang/fitdit

## Overview

##### Main Components Identification

a. Preprocessing Pipeline:
- DWPose Module (/preprocess/dwpose)
- Human Parsing Module (/preprocess/humanparsing)

b. Core Processing Components:
- Attention Mechanisms (src/attention_garm.py, src/attention_vton.py)
- Transformers (src/transformer_sd3_garm.py, src/transformer_sd3_vton.py)
- Pose Guider (src/pose_guider.py)

c. Pipeline Orchestrator:
- Main Pipeline (src/pipeline_stable_diffusion_3_tryon.py)

**[Input Layer]**

- Model Image
- Garment Image

**[Preprocessing Layer]**

- DWPose Processing
- Pose Estimation

- Human Parsing
- Segmentation Masks

**[Core Processing Layer]**

- Pose Guider
- Pose-aware Feature Extraction

- Attention Mechanisms
- GARM Attention
- VTON Attention

- Transformers
- GARM Transformer
- VTON Transformer

**[Output Layer]**

- Try-on Result

##### Important Design Elements

- Two-step process mentioned in the README:
1. Mask Generation
2. Try-on Generation

b. Processing Stages:
- Resolution handling (1152x1536 default)
- Mask adjustment capabilities
- Different precision options (bf16, fp16)

c. Memory Management:
- Offload options (CPU offload, aggressive offload)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        MI[Model Image]:::input
        GI[Garment Image]:::input
    end

    subgraph Preprocessing
        DW[DWPose Module]:::preprocess
        HP[Human Parsing]:::preprocess
        PE[Pose Estimation]:::preprocess
        SM[Segmentation Masks]:::preprocess
    end

    subgraph CoreProcessing
        PG[Pose Guider]:::core
        
        subgraph Attention
            GA[GARM Attention]:::attention
            VA[VTON Attention]:::attention
            GAP[GARM Attention Processor]:::attention
            VAP[VTON Attention Processor]:::attention
        end
        
        subgraph Transformers
            GT[GARM Transformer]:::transformer
            VT[VTON Transformer]:::transformer
        end
    end

    subgraph Pipeline
        PO[Pipeline Orchestrator]:::pipeline
        MU[Mask Utilities]:::utility
    end

    subgraph Output
        TR[Try-on Result]:::output
    end

    MI --> DW
    GI --> DW
    DW --> PE
    PE --> PG
    MI --> HP
    HP --> SM
    SM --> PG

    PG --> GA
    PG --> VA
    GA --> GAP
    VA --> VAP
    GAP --> GT
    VAP --> VT
    GT --> PO
    VT --> PO
    PO --> MU
    MU --> TR

    click DW "https://github.com/BoyuanJiang/FitDiT/tree/main/preprocess/dwpose/"
    click HP "https://github.com/BoyuanJiang/FitDiT/tree/main/preprocess/humanparsing/"
    click GA "https://github.com/BoyuanJiang/FitDiT/blob/main/src/attention_garm.py"
    click VA "https://github.com/BoyuanJiang/FitDiT/blob/main/src/attention_vton.py"
    click GT "https://github.com/BoyuanJiang/FitDiT/blob/main/src/transformer_sd3_garm.py"
    click VT "https://github.com/BoyuanJiang/FitDiT/blob/main/src/transformer_sd3_vton.py"
    click PG "https://github.com/BoyuanJiang/FitDiT/blob/main/src/pose_guider.py"
    click PO "https://github.com/BoyuanJiang/FitDiT/blob/main/src/pipeline_stable_diffusion_3_tryon.py"
    click MU "https://github.com/BoyuanJiang/FitDiT/blob/main/src/utils_mask.py"
    click GAP "https://github.com/BoyuanJiang/FitDiT/blob/main/src/attention_processor_garm.py"
    click VAP "https://github.com/BoyuanJiang/FitDiT/blob/main/src/attention_processor_vton.py"

    classDef input fill:#2196F3,stroke:#000,stroke-width:2px
    classDef preprocess fill:#4CAF50,stroke:#000,stroke-width:2px
    classDef core fill:#FF9800,stroke:#000,stroke-width:2px
    classDef attention fill:#9C27B0,stroke:#000,stroke-width:2px
    classDef transformer fill:#9C27B0,stroke:#000,stroke-width:2px
    classDef pipeline fill:#607D8B,stroke:#000,stroke-width:2px
    classDef utility fill:#757575,stroke:#000,stroke-width:2px
    classDef output fill:#2196F3,stroke:#000,stroke-width:2px
```
