# aerovilab-ahu/lwganet architecture

> Architecture diagram of the GitHub repository aerovilab-ahu/lwganet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aerovilab-ahu/lwganet
- Repository: https://github.com/aerovilab-ahu/lwganet

## Overview

LWGANet is a PyTorch remote-sensing vision repository spanning image classification, oriented object detection, semantic segmentation, and change detection. Users prepare task-specific imagery and labels, configure a model, then train or run inference to obtain class, object, mask, or change predictions. The shared architectural idea is the lightweight LWGANet backbone, while each task has its own data and model stack. The graph preserves documented task capabilities; some subsystem internals are unsampled, so only evidenced or README-documented connections are shown.

Main entry points: [`segmentation/tools/cfg.py`](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/tools/cfg.py) (Task configuration), [`change_detection/A2Net_LWGANet/train.py`](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/train.py) (A2Net training), [`change_detection/CLAFA_LWGANet/main.py`](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/main.py) (CLAFA training entry), [`segmentation/train_supervision.py`](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/train_supervision.py) (Segmentation training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared Backbone"]
  node_lwga["LWGANet models"]
end

subgraph group_classification["Classification"]
  node_class_train["Classifier training<br/>[train.py]"]
  node_class_data["Classification data utilities<br/>[utils.py]"]
  node_class_models["Alternative backbones"]
  node_class_edgenext["EdgeNeXt blocks"]
  node_class_split["Dataset splitting"]
end

subgraph group_detection["Oriented Detection"]
  node_detection_train["Detection training entry<br/>[train.py]"]
  node_det_api["Train and inference APIs"]
  node_det_datasets["Rotated datasets"]
  node_det_models["Detector architectures"]
  node_det_backbone["LWGANet detector backbone<br/>[lwganet.py]"]
  node_det_heads["Detection heads"]
  node_det_core["Rotated-box utilities"]
  node_det_infer["Patch inference<br/>[inference.py]"]
end

subgraph group_segmentation["Semantic Segmentation"]
  node_seg_train["Segmentation training"]
  node_seg_config["Task configuration<br/>[cfg.py]"]
  node_seg_data["Segmentation datasets"]
  node_seg_transform["Dataset transforms<br/>[transform.py]"]
  node_seg_models["Segmentation models"]
  node_seg_unet["UNetFormer model<br/>[UNetFormer.py]"]
  node_seg_losses["Segmentation losses"]
  node_seg_infer["Large-image inference"]
  node_seg_uavid_infer["UAVid inference<br/>[inference_uavid.py]"]
end

subgraph group_change["Change Detection"]
  node_change_a2_train["A2Net training<br/>[train.py]"]
  node_change_a2_data["A2Net dataset<br/>[dataset.py]"]
  node_change_a2_transform["A2Net transforms<br/>[Transforms.py]"]
  node_change_a2_model["A2Net model family"]
  node_change_clafa_main["CLAFA training entry<br/>[main.py]"]
  node_change_clafa_data["CLAFA dataset<br/>[cd_dataset.py]"]
  node_change_clafa_factory["CLAFA model factory<br/>[create_model.py]"]
  node_change_clafa_backbone["CLAFA LWGANet backbone<br/>[lwganet.py]"]
  node_change_metrics["Change metrics<br/>[metric_tool.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"trains classifier"| node_class_train
node_researcher -->|"trains detector"| node_detection_train
node_researcher -->|"trains segmenter"| node_seg_train
node_researcher -->|"trains change model"| node_change_a2_train
node_researcher -->|"trains change model"| node_change_clafa_main
node_class_train -->|"uses utilities"| node_class_data
node_class_data -->|"selects backbone"| node_lwga
node_class_data -->|"selects models"| node_class_models
node_class_edgenext -->|"implements backbone"| node_class_models
node_detection_train -->|"uses APIs"| node_det_api
node_det_api -->|"imports utilities"| node_det_core
node_det_infer -->|"merges patches"| node_det_core
node_det_backbone -.->|"implements backbone"| node_lwga
node_seg_train -->|"loads configuration"| node_seg_config
node_seg_config -->|"configures datasets"| node_seg_data
node_seg_config -->|"configures model"| node_seg_unet
node_seg_config -->|"configures losses"| node_seg_losses
node_seg_data -->|"uses transforms"| node_seg_transform
node_seg_infer -->|"loads configuration"| node_seg_config
node_seg_infer -->|"loads trained model"| node_seg_train
node_seg_uavid_infer -->|"loads configuration"| node_seg_config
node_seg_uavid_infer -->|"loads trained model"| node_seg_train
node_change_a2_train -->|"loads data"| node_change_a2_data
node_change_a2_train -->|"applies transforms"| node_change_a2_transform
node_change_a2_train -->|"uses model"| node_change_a2_model
node_change_clafa_main -->|"loads data"| node_change_clafa_data
node_change_clafa_main -->|"creates model"| node_change_clafa_factory
node_change_clafa_main -->|"reports metrics"| node_change_metrics
node_change_clafa_factory -->|"builds network"| node_change_clafa_backbone

click node_lwga "https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models"
click node_class_train "https://github.com/aerovilab-ahu/lwganet/blob/main/classification/train.py"
click node_class_data "https://github.com/aerovilab-ahu/lwganet/blob/main/classification/utils.py"
click node_class_models "https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models"
click node_class_edgenext "https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models/edgenext"
click node_class_split "https://github.com/aerovilab-ahu/lwganet/blob/main/classification/split_datasets/split_train_val_dataset.py"
click node_detection_train "https://github.com/aerovilab-ahu/lwganet/blob/main/detection/tools/train.py"
click node_det_api "https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/apis"
click node_det_datasets "https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/datasets"
click node_det_models "https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/models/detectors"
click node_det_backbone "https://github.com/aerovilab-ahu/lwganet/blob/main/detection/mmrotate/models/backbones/lwganet.py"
click node_det_heads "https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/models/dense_heads"
click node_det_core "https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/core"
click node_det_infer "https://github.com/aerovilab-ahu/lwganet/blob/main/detection/mmrotate/apis/inference.py"
click node_seg_train "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/train_supervision.py"
click node_seg_config "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/tools/cfg.py"
click node_seg_data "https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/datasets"
click node_seg_transform "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/geoseg/datasets/transform.py"
click node_seg_models "https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/models"
click node_seg_unet "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/geoseg/models/UNetFormer.py"
click node_seg_losses "https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/losses"
click node_seg_infer "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/inference_huge_image.py"
click node_seg_uavid_infer "https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/inference_uavid.py"
click node_change_a2_train "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/train.py"
click node_change_a2_data "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/dataset.py"
click node_change_a2_transform "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/Transforms.py"
click node_change_a2_model "https://github.com/aerovilab-ahu/lwganet/tree/main/change_detection/A2Net_LWGANet/models"
click node_change_clafa_main "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/main.py"
click node_change_clafa_data "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/data/cd_dataset.py"
click node_change_clafa_factory "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/model/create_model.py"
click node_change_clafa_backbone "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/model/backbone/lwganet.py"
click node_change_metrics "https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/util/metric_tool.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lwga toneBlue
class node_class_train,node_class_data,node_class_models,node_class_edgenext,node_class_split toneAmber
class node_detection_train,node_det_api,node_det_datasets,node_det_models,node_det_backbone,node_det_heads,node_det_core,node_det_infer toneMint
class node_seg_train,node_seg_config,node_seg_data,node_seg_transform,node_seg_models,node_seg_unet,node_seg_losses,node_seg_infer,node_seg_uavid_infer toneRose
class node_change_a2_train,node_change_a2_data,node_change_a2_transform,node_change_a2_model,node_change_clafa_main,node_change_clafa_data,node_change_clafa_factory,node_change_clafa_backbone,node_change_metrics,node_researcher toneIndigo
```

## Components

### Shared Backbone

- [LWGANet models](https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models): `classification/models`

### Classification

- [Classifier training](https://github.com/aerovilab-ahu/lwganet/blob/main/classification/train.py): `classification/train.py`
- [Classification data utilities](https://github.com/aerovilab-ahu/lwganet/blob/main/classification/utils.py): `classification/utils.py`
- [Alternative backbones](https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models): `classification/models`
- [EdgeNeXt blocks](https://github.com/aerovilab-ahu/lwganet/tree/main/classification/models/edgenext): `classification/models/edgenext`
- [Dataset splitting](https://github.com/aerovilab-ahu/lwganet/blob/main/classification/split_datasets/split_train_val_dataset.py): `classification/split_datasets/split_train_val_dataset.py`

### Oriented Detection

- [Detection training entry](https://github.com/aerovilab-ahu/lwganet/blob/main/detection/tools/train.py): `detection/tools/train.py`
- [Train and inference APIs](https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/apis): `detection/mmrotate/apis`
- [Rotated datasets](https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/datasets): `detection/mmrotate/datasets`
- [Detector architectures](https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/models/detectors): `detection/mmrotate/models/detectors`
- [LWGANet detector backbone](https://github.com/aerovilab-ahu/lwganet/blob/main/detection/mmrotate/models/backbones/lwganet.py): `detection/mmrotate/models/backbones/lwganet.py`
- [Detection heads](https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/models/dense_heads): `detection/mmrotate/models/dense_heads`
- [Rotated-box utilities](https://github.com/aerovilab-ahu/lwganet/tree/main/detection/mmrotate/core): `detection/mmrotate/core`
- [Patch inference](https://github.com/aerovilab-ahu/lwganet/blob/main/detection/mmrotate/apis/inference.py): `detection/mmrotate/apis/inference.py`

### Semantic Segmentation

- [Segmentation training](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/train_supervision.py): `segmentation/train_supervision.py`
- [Task configuration](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/tools/cfg.py): `segmentation/tools/cfg.py`
- [Segmentation datasets](https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/datasets): `segmentation/geoseg/datasets`
- [Dataset transforms](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/geoseg/datasets/transform.py): `segmentation/geoseg/datasets/transform.py`
- [Segmentation models](https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/models): `segmentation/geoseg/models`
- [UNetFormer model](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/geoseg/models/UNetFormer.py): `segmentation/geoseg/models/UNetFormer.py`
- [Segmentation losses](https://github.com/aerovilab-ahu/lwganet/tree/main/segmentation/geoseg/losses): `segmentation/geoseg/losses`
- [Large-image inference](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/inference_huge_image.py): `segmentation/inference_huge_image.py`
- [UAVid inference](https://github.com/aerovilab-ahu/lwganet/blob/main/segmentation/inference_uavid.py): `segmentation/inference_uavid.py`

### Change Detection

- [A2Net training](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/train.py): `change_detection/A2Net_LWGANet/train.py`
- [A2Net dataset](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/dataset.py): `change_detection/A2Net_LWGANet/dataset.py`
- [A2Net transforms](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/A2Net_LWGANet/Transforms.py): `change_detection/A2Net_LWGANet/Transforms.py`
- [A2Net model family](https://github.com/aerovilab-ahu/lwganet/tree/main/change_detection/A2Net_LWGANet/models): `change_detection/A2Net_LWGANet/models`
- [CLAFA training entry](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/main.py): `change_detection/CLAFA_LWGANet/main.py`
- [CLAFA dataset](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/data/cd_dataset.py): `change_detection/CLAFA_LWGANet/data/cd_dataset.py`
- [CLAFA model factory](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/model/create_model.py): `change_detection/CLAFA_LWGANet/model/create_model.py`
- [CLAFA LWGANet backbone](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/model/backbone/lwganet.py): `change_detection/CLAFA_LWGANet/model/backbone/lwganet.py`
- [Change metrics](https://github.com/aerovilab-ahu/lwganet/blob/main/change_detection/CLAFA_LWGANet/util/metric_tool.py): `change_detection/CLAFA_LWGANet/util/metric_tool.py`

### Other components

- **Researcher**

## Connections

- Researcher → Classifier training: trains classifier (evidence: `README.md`)
- Researcher → Detection training entry: trains detector (evidence: `README.md`)
- Researcher → Segmentation training: trains segmenter (evidence: `README.md`)
- Researcher → A2Net training: trains change model (evidence: `README.md`)
- Researcher → CLAFA training entry: trains change model (evidence: `README.md`)
- Classifier training → Classification data utilities: uses utilities (evidence: `classification/train.py`)
- Classification data utilities → LWGANet models: selects backbone (evidence: `classification/utils.py`)
- Classification data utilities → Alternative backbones: selects models (evidence: `classification/utils.py`)
- EdgeNeXt blocks → Alternative backbones: implements backbone (evidence: `classification/models/edgenext/edgenext.py`)
- Detection training entry → Train and inference APIs: uses APIs (evidence: `detection/tools/train.py`)
- Train and inference APIs → Rotated-box utilities: imports utilities (evidence: `detection/mmrotate/apis/inference.py`)
- Patch inference → Rotated-box utilities: merges patches (evidence: `detection/mmrotate/apis/inference.py`)
- LWGANet detector backbone → LWGANet models: implements backbone
- Segmentation training → Task configuration: loads configuration (evidence: `segmentation/train_supervision.py`)
- Task configuration → Segmentation datasets: configures datasets
- Task configuration → UNetFormer model: configures model
- Task configuration → Segmentation losses: configures losses
- Segmentation datasets → Dataset transforms: uses transforms (evidence: `segmentation/geoseg/datasets/uavid_dataset.py`)
- Large-image inference → Task configuration: loads configuration (evidence: `segmentation/inference_huge_image.py`)
- Large-image inference → Segmentation training: loads trained model (evidence: `segmentation/inference_huge_image.py`)
- UAVid inference → Task configuration: loads configuration (evidence: `segmentation/inference_uavid.py`)
- UAVid inference → Segmentation training: loads trained model (evidence: `segmentation/inference_uavid.py`)
- A2Net training → A2Net dataset: loads data (evidence: `change_detection/A2Net_LWGANet/train.py`)
- A2Net training → A2Net transforms: applies transforms (evidence: `change_detection/A2Net_LWGANet/train.py`)
- A2Net training → A2Net model family: uses model (evidence: `change_detection/A2Net_LWGANet/train.py`)
- CLAFA training entry → CLAFA dataset: loads data (evidence: `change_detection/CLAFA_LWGANet/main.py`)
- CLAFA training entry → CLAFA model factory: creates model (evidence: `change_detection/CLAFA_LWGANet/main.py`)
- CLAFA training entry → Change metrics: reports metrics (evidence: `change_detection/CLAFA_LWGANet/main.py`)
- CLAFA model factory → CLAFA LWGANet backbone: builds network (evidence: `change_detection/CLAFA_LWGANet/model/create_model.py`)
