# pui-nantheera/dmat architecture

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

- Interactive diagram: https://gitdiagram.com/pui-nantheera/dmat
- Repository: https://github.com/pui-nantheera/dmat

## Overview

DMAT is presented as a framework for atmospheric-turbulence mitigation and object detection, but the available tree and source excerpts primarily support video restoration: paired-video training and trained-model inference. The documented one/two-stage option and Swin3D/Mamba alternatives are represented; detection implementation is not evident in the supplied files. Training and dataset wiring are supported by excerpts, while testing behavior and several model variants are documented or named in the tree but not sampled, so their internal links are limited.

Main entry points: [`code/train.py`](https://github.com/pui-nantheera/dmat/blob/main/code/train.py) (Train model), [`code/test.py`](https://github.com/pui-nantheera/dmat/blob/main/code/test.py) (Video inference), [`code/test_folder.py`](https://github.com/pui-nantheera/dmat/blob/main/code/test_folder.py) (Folder inference), [`code/model/TMT_DC.py`](https://github.com/pui-nantheera/dmat/blob/main/code/model/TMT_DC.py) (TMT model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Video workflows"]
  node_training["Train model<br/>[train.py]"]
  node_video_test["Video inference<br/>[test.py]"]
  node_folder_test["Folder inference<br/>[test_folder.py]"]
end

subgraph group_learning["Training components"]
  node_video_dataset["Video dataset"]
  node_charbonnier["Charbonnier loss<br/>[losses.py]"]
  node_scheduler["Learning-rate scheduler<br/>[scheduler.py]"]
  node_run_utils["Checkpoint utilities<br/>[general.py]"]
end

subgraph group_networks["Restoration networks"]
  node_tmt["TMT model<br/>[TMT_DC.py]"]
  node_swin["Swin 3D<br/>[SwinUnet_3D.py]"]
  node_mamba["Mamba 3D<br/>[nnMamba.py]"]
  node_deform["Deformable convolution<br/>[DefConv.py]"]
end

subgraph group_support["Auxiliary modules"]
  node_fd_loss["Fractal-dimension loss<br/>[fd_loss.py]"]
  node_fd_model["FD regression model<br/>[FD_LOSS_Model.py]"]
  node_canny["Canny edge network<br/>[net_canny.py]"]
end

node_researcher(("User"))
node_paired_videos["Paired videos"]
node_restored["Restored media"]
node_checkpoints["Model checkpoints"]

node_researcher -->|"starts training"| node_training
node_paired_videos -->|"provides pairs"| node_video_dataset
node_training -->|"loads batches"| node_video_dataset
node_video_dataset -->|"returns frames"| node_training
node_training -->|"trains"| node_tmt
node_training -->|"computes loss"| node_charbonnier
node_training -->|"steps schedule"| node_scheduler
node_training -->|"creates run folders"| node_run_utils
node_training -->|"saves weights"| node_checkpoints
node_researcher -->|"starts inference"| node_video_test
node_researcher -->|"starts inference"| node_folder_test
node_checkpoints -->|"loads weights"| node_video_test
node_checkpoints -->|"loads weights"| node_folder_test
node_video_test -->|"runs model"| node_tmt
node_folder_test -->|"runs model"| node_tmt
node_video_test -->|"writes output"| node_restored
node_folder_test -->|"writes output"| node_restored
node_tmt -->|"uses layers"| node_deform
node_fd_loss -->|"uses edges"| node_canny

click node_training "https://github.com/pui-nantheera/dmat/blob/main/code/train.py"
click node_video_test "https://github.com/pui-nantheera/dmat/blob/main/code/test.py"
click node_folder_test "https://github.com/pui-nantheera/dmat/blob/main/code/test_folder.py"
click node_video_dataset "https://github.com/pui-nantheera/dmat/blob/main/code/data/dataset_video_train.py"
click node_charbonnier "https://github.com/pui-nantheera/dmat/blob/main/code/utils/losses.py"
click node_scheduler "https://github.com/pui-nantheera/dmat/blob/main/code/utils/scheduler.py"
click node_run_utils "https://github.com/pui-nantheera/dmat/blob/main/code/utils/general.py"
click node_tmt "https://github.com/pui-nantheera/dmat/blob/main/code/model/TMT_DC.py"
click node_swin "https://github.com/pui-nantheera/dmat/blob/main/code/model/SwinUnet_3D.py"
click node_mamba "https://github.com/pui-nantheera/dmat/blob/main/code/model/nnMamba.py"
click node_deform "https://github.com/pui-nantheera/dmat/blob/main/code/model/DefConv.py"
click node_fd_loss "https://github.com/pui-nantheera/dmat/blob/main/code/FD/fd_loss.py"
click node_fd_model "https://github.com/pui-nantheera/dmat/blob/main/code/FD/FD_LOSS_Model.py"
click node_canny "https://github.com/pui-nantheera/dmat/blob/main/code/FD/net_canny.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_training,node_video_test,node_folder_test,node_researcher toneBlue
class node_video_dataset,node_charbonnier,node_scheduler,node_run_utils toneAmber
class node_tmt,node_swin,node_mamba,node_deform toneMint
class node_fd_loss,node_fd_model,node_canny toneRose
class node_paired_videos,node_restored,node_checkpoints toneIndigo
```

## Components

### Video workflows

- [Train model](https://github.com/pui-nantheera/dmat/blob/main/code/train.py): `code/train.py`
- [Video inference](https://github.com/pui-nantheera/dmat/blob/main/code/test.py): `code/test.py`
- [Folder inference](https://github.com/pui-nantheera/dmat/blob/main/code/test_folder.py): `code/test_folder.py`

### Training components

- [Video dataset](https://github.com/pui-nantheera/dmat/blob/main/code/data/dataset_video_train.py): `code/data/dataset_video_train.py`
- [Charbonnier loss](https://github.com/pui-nantheera/dmat/blob/main/code/utils/losses.py): `code/utils/losses.py`
- [Learning-rate scheduler](https://github.com/pui-nantheera/dmat/blob/main/code/utils/scheduler.py): `code/utils/scheduler.py`
- [Checkpoint utilities](https://github.com/pui-nantheera/dmat/blob/main/code/utils/general.py): `code/utils/general.py`

### Restoration networks

- [TMT model](https://github.com/pui-nantheera/dmat/blob/main/code/model/TMT_DC.py): `code/model/TMT_DC.py`
- [Swin 3D](https://github.com/pui-nantheera/dmat/blob/main/code/model/SwinUnet_3D.py): `code/model/SwinUnet_3D.py`
- [Mamba 3D](https://github.com/pui-nantheera/dmat/blob/main/code/model/nnMamba.py): `code/model/nnMamba.py`
- [Deformable convolution](https://github.com/pui-nantheera/dmat/blob/main/code/model/DefConv.py): `code/model/DefConv.py`

### Auxiliary modules

- [Fractal-dimension loss](https://github.com/pui-nantheera/dmat/blob/main/code/FD/fd_loss.py): `code/FD/fd_loss.py`
- [FD regression model](https://github.com/pui-nantheera/dmat/blob/main/code/FD/FD_LOSS_Model.py): `code/FD/FD_LOSS_Model.py`
- [Canny edge network](https://github.com/pui-nantheera/dmat/blob/main/code/FD/net_canny.py): `code/FD/net_canny.py`

### Other components

- **User**
- **Paired videos**
- **Restored media**
- **Model checkpoints**

## Connections

- User → Train model: starts training
- Paired videos → Video dataset: provides pairs
- Train model → Video dataset: loads batches
- Video dataset → Train model: returns frames
- Train model → TMT model: trains
- Train model → Charbonnier loss: computes loss
- Train model → Learning-rate scheduler: steps schedule
- Train model → Checkpoint utilities: creates run folders
- Train model → Model checkpoints: saves weights
- User → Video inference: starts inference
- User → Folder inference: starts inference
- Model checkpoints → Video inference: loads weights
- Model checkpoints → Folder inference: loads weights
- Video inference → TMT model: runs model
- Folder inference → TMT model: runs model
- Video inference → Restored media: writes output
- Folder inference → Restored media: writes output
- TMT model → Deformable convolution: uses layers
- Fractal-dimension loss → Canny edge network: uses edges
