# another-0/dmm architecture

> Architecture diagram of the GitHub repository another-0/dmm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/another-0/dmm
- Repository: https://github.com/another-0/dmm

## Overview

#### Purpose and Entry Points
This repository implements DMM, a disparity-guided multispectral Mamba detector for oriented remote-sensing object detection, built on MMRotate/MMDetection/MMEngine. Primary CLI entry points are `tools/train.py` and `tools/test.py`; single-image and huge-image inference are exposed through `mmrotate/apis/inference.py`, `demo/image_demo.py`, and `demo/huge_image_demo.py`.

#### Configuration-Driven Execution
Experiments are Python configurations that compose model, dataset, schedule, and runtime defaults. The DMM experiment is `configs/dmm/dmm_s2anet_1x_dronevehicle.py`; shared DroneVehicle dataset settings and standard runtime defaults are in `configs/_base_/datasets/DroneVehicle.py` and `configs/_base_/default_runtime.py`. The framework registry boundary is `mmrotate/registry.py`, allowing configs to instantiate local components alongside upstream OpenMMLab modules.

#### Data Preparation and Dataset Pipeline
DroneVehicle is the intended DMM input: source imagery is preprocessed to crop white borders by `tools/data_process.py`, and VOC-style labels are normalized/conveted to DOTA annotations by `tools/VOC2DOTA.py`. Dataset adapters load oriented annotations and samples through `mmrotate/datasets/dronevehicle.py`, while loading and geometric/image transforms reside in `mmrotate/datasets/transforms/loading.py` and `mmrotate/datasets/transforms/transforms.py`. This boundary converts filesystem images and polygon annotations into model-ready tensors and rotated-box data samples.

#### Geometric Representation and Detection Semantics
The core domain abstraction is rotated or quadrilateral bounding boxes, with conversion, transforms, and overlap operations under `mmrotate/structures/bbox/rotated_boxes.py`, `mmrotate/structures/bbox/quadri_boxes.py`, and `mmrotate/structures/bbox/box_converters.py`. Heads, assigners, coders, and losses consume these representations, preserving orientation throughout training, proposal assignment, decoding, NMS, and evaluation rather than treating targets as axis-aligned boxes.

#### DMM Model Path
DMM is implemented as a specialized S2ANet-style detector in `mmrotate/models/detectors/dmm_s2anet.py`. Its multispectral/disparity fusion layer is `mmrotate/models/layers/dmm/rgbtmamba.py`, supported by state-space utilities in `mmrotate/models/layers/dmm/ssm_utils.py`; the VMamba backbone implementation and selective-scan integration are under `mmrotate/models/backbones/vmamba/vmamba.py` and `mmrotate/models/backbones/vmamba/csms6s.py`. RGB/Thermal inputs are preprocessed by `mmrotate/models/layers/rgbtDetDataPreprocessor.py` before feature extraction, fusion, alignment, and oriented dense prediction.

#### General Detection Building Blocks
The repository retains MMRotate’s configurable detector ecosystem: dense oriented prediction heads include `mmrotate/models/dense_heads/s2a_head.py`, `mmrotate/models/dense_heads/rotated_retina_head.py`, and `mmrotate/models/dense_heads/rotated_rtmdet_head.py`; detector orchestration includes `mmrotate/models/detectors/refine_single_stage.py`. Training supervision is mediated by rotated assignment/coding modules such as `mmrotate/models/task_modules/assigners/rotated_atss_assigner.py` and `mmrotate/models/task_modules/coders/delta_xywht_rbbox_coder.py`, with specialized rotated losses in `mmrotate/models/losses/rotated_iou_loss.py`.

#### Evaluation, Deployment, and Runtime Dependencies
Predictions are scored using DOTA and rotated-COCO metrics in `mmrotate/evaluation/metrics/dota_metric.py` and `mmrotate/evaluation/metrics/rotated_coco_metric.py`, and can be rendered via `mmrotate/visualization/local_visualizer.py`. Large-image workflows can split and merge patch results through `mmrotate/utils/patch/split.py` and `mmrotate/utils/patch/merge_results.py`. The material runtime is Python/PyTorch with CUDA 11.8, MMDetection 3.3.0, MMCV 2.1.0, and MMEngine 0.10.5; DMM additionally depends on VMamba’s `selective_scan==0.0.2`. Optional serving integration targets TorchServe through `tools/deployment/mmrotate2torchserve.py` and `tools/deployment/mmrotate_handler.py`.

Main entry points: [`mmrotate/models/detectors/dmm_s2anet.py`](https://github.com/another-0/dmm/blob/main/mmrotate/models/detectors/dmm_s2anet.py) (DMM S2ANet detector), [`configs/dmm/dmm_s2anet_1x_dronevehicle.py`](https://github.com/another-0/dmm/blob/main/configs/dmm/dmm_s2anet_1x_dronevehicle.py) (DMM experiment config), [`mmrotate/datasets/transforms/transforms.py`](https://github.com/another-0/dmm/blob/main/mmrotate/datasets/transforms/transforms.py) (Load & geometric transforms), [`mmrotate/models/dense_heads/s2a_head.py`](https://github.com/another-0/dmm/blob/main/mmrotate/models/dense_heads/s2a_head.py) (Oriented dense heads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry &amp; Config"]
  node_train["Training CLI<br/>[train.py]"]
  node_test["Test CLI<br/>[test.py]"]
  node_dmm_config["DMM experiment config<br/>Python config"]
  node_dataset_config["DroneVehicle config<br/>Dataset config<br/>[DroneVehicle.py]"]
  node_registry{{"MMRotate registry<br/>[registry.py]"}}
end

subgraph group_data["Data &amp; Geometry"]
  node_prepare_data["Dataset preparation<br/>Conversion tools<br/>[data_process.py]"]
  node_dronevehicle["DroneVehicle dataset<br/>Dataset adapter<br/>[dronevehicle.py]"]
  node_transforms["Load &amp; geometric transforms<br/>Pipeline transforms<br/>[transforms.py]"]
  node_rotated_boxes["Rotated box structures<br/>Geometry<br/>[rotated_boxes.py]"]
end

subgraph group_model["DMM Model"]
  node_preprocessor["RGB/T data preprocessor<br/>Model preprocessor"]
  node_dmm_detector["DMM S2ANet detector<br/>Oriented detector<br/>[dmm_s2anet.py]"]
  node_vmamba["VMamba backbone<br/>[vmamba.py]"]
  node_selective_scan{{"Selective scan<br/>CUDA state-space op<br/>[csms6s.py]"}}
  node_rgbt_mamba["RGBT Mamba fusion<br/>Fusion layer<br/>[rgbtmamba.py]"]
  node_oriented_heads["Oriented dense heads<br/>Detection heads<br/>[s2a_head.py]"]
  node_supervision["Rotated supervision<br/>Assigner, coder &amp; loss"]
end

subgraph group_runtime["Evaluation &amp; Deployment"]
  node_metrics["DOTA metrics<br/>Evaluation metric<br/>[dota_metric.py]"]
  node_inference["Inference API<br/>[inference.py]"]
  node_patching["Large-image patching<br/>Patch workflow<br/>[split.py]"]
  node_visualizer["Local visualizer<br/>Visualization"]
  node_torchserve["TorchServe export<br/>Serving integration"]
end

node_train -->|"loads"| node_dmm_config
node_test -->|"loads"| node_dmm_config
node_dmm_config -->|"inherits"| node_dataset_config
node_dmm_config -->|"builds through"| node_registry
node_dmm_config -->|"selects"| node_dmm_detector
node_prepare_data -->|"produces normalized input for"| node_dronevehicle
node_dataset_config -->|"configures"| node_dronevehicle
node_dronevehicle -->|"feeds samples through"| node_transforms
node_transforms -->|"creates and transforms"| node_rotated_boxes
node_transforms -->|"delivers tensors to"| node_preprocessor
node_preprocessor -->|"prepares inputs for"| node_dmm_detector
node_dmm_detector -->|"extracts features with"| node_vmamba
node_vmamba -->|"uses"| node_selective_scan
node_dmm_detector -->|"fuses modalities through"| node_rgbt_mamba
node_dmm_detector -->|"predicts through"| node_oriented_heads
node_oriented_heads -->|"trains with"| node_supervision
node_supervision -->|"consumes oriented targets"| node_rotated_boxes
node_test -->|"evaluates with"| node_metrics
node_oriented_heads -->|"emits predictions for"| node_metrics
node_inference -->|"runs"| node_dmm_detector
node_inference -->|"uses for huge images"| node_patching
node_patching -->|"renders merged results"| node_visualizer
node_dmm_detector -.->|"optionally packaged for"| node_torchserve

click node_train "https://github.com/another-0/dmm/blob/main/tools/train.py"
click node_test "https://github.com/another-0/dmm/blob/main/tools/test.py"
click node_dmm_config "https://github.com/another-0/dmm/blob/main/configs/dmm/dmm_s2anet_1x_dronevehicle.py"
click node_dataset_config "https://github.com/another-0/dmm/blob/main/configs/_base_/datasets/DroneVehicle.py"
click node_registry "https://github.com/another-0/dmm/blob/main/mmrotate/registry.py"
click node_prepare_data "https://github.com/another-0/dmm/blob/main/tools/data_process.py"
click node_dronevehicle "https://github.com/another-0/dmm/blob/main/mmrotate/datasets/dronevehicle.py"
click node_transforms "https://github.com/another-0/dmm/blob/main/mmrotate/datasets/transforms/transforms.py"
click node_rotated_boxes "https://github.com/another-0/dmm/blob/main/mmrotate/structures/bbox/rotated_boxes.py"
click node_preprocessor "https://github.com/another-0/dmm/blob/main/mmrotate/models/layers/rgbtDetDataPreprocessor.py"
click node_dmm_detector "https://github.com/another-0/dmm/blob/main/mmrotate/models/detectors/dmm_s2anet.py"
click node_vmamba "https://github.com/another-0/dmm/blob/main/mmrotate/models/backbones/vmamba/vmamba.py"
click node_selective_scan "https://github.com/another-0/dmm/blob/main/mmrotate/models/backbones/vmamba/csms6s.py"
click node_rgbt_mamba "https://github.com/another-0/dmm/blob/main/mmrotate/models/layers/dmm/rgbtmamba.py"
click node_oriented_heads "https://github.com/another-0/dmm/blob/main/mmrotate/models/dense_heads/s2a_head.py"
click node_supervision "https://github.com/another-0/dmm/blob/main/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py"
click node_metrics "https://github.com/another-0/dmm/blob/main/mmrotate/evaluation/metrics/dota_metric.py"
click node_inference "https://github.com/another-0/dmm/blob/main/mmrotate/apis/inference.py"
click node_patching "https://github.com/another-0/dmm/blob/main/mmrotate/utils/patch/split.py"
click node_visualizer "https://github.com/another-0/dmm/blob/main/mmrotate/visualization/local_visualizer.py"
click node_torchserve "https://github.com/another-0/dmm/blob/main/tools/deployment/mmrotate2torchserve.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_train,node_test,node_dmm_config,node_dataset_config,node_registry toneBlue
class node_prepare_data,node_dronevehicle,node_transforms,node_rotated_boxes toneAmber
class node_preprocessor,node_dmm_detector,node_vmamba,node_selective_scan,node_rgbt_mamba,node_oriented_heads,node_supervision toneMint
class node_metrics,node_inference,node_patching,node_visualizer,node_torchserve toneRose
```

## Components

### Entry & Config

- [Training CLI](https://github.com/another-0/dmm/blob/main/tools/train.py): CLI · `tools/train.py`
- [Test CLI](https://github.com/another-0/dmm/blob/main/tools/test.py): CLI · `tools/test.py`
- [DMM experiment config](https://github.com/another-0/dmm/blob/main/configs/dmm/dmm_s2anet_1x_dronevehicle.py): Python config · Composes DMM, DroneVehicle, schedule, and runtime settings. · `configs/dmm/dmm_s2anet_1x_dronevehicle.py`
- [DroneVehicle config](https://github.com/another-0/dmm/blob/main/configs/_base_/datasets/DroneVehicle.py): Dataset config · `configs/_base_/datasets/DroneVehicle.py`
- [MMRotate registry](https://github.com/another-0/dmm/blob/main/mmrotate/registry.py): Registry · Instantiates local and upstream OpenMMLab components. · `mmrotate/registry.py`

### Data & Geometry

- [Dataset preparation](https://github.com/another-0/dmm/blob/main/tools/data_process.py): Conversion tools · Crops white borders and converts VOC labels to DOTA. · `tools/data_process.py`
- [DroneVehicle dataset](https://github.com/another-0/dmm/blob/main/mmrotate/datasets/dronevehicle.py): Dataset adapter · Loads multispectral images and oriented annotations. · `mmrotate/datasets/dronevehicle.py`
- [Load & geometric transforms](https://github.com/another-0/dmm/blob/main/mmrotate/datasets/transforms/transforms.py): Pipeline transforms · `mmrotate/datasets/transforms/transforms.py`
- [Rotated box structures](https://github.com/another-0/dmm/blob/main/mmrotate/structures/bbox/rotated_boxes.py): Geometry · Rotated/quadrilateral conversion and overlap semantics. · `mmrotate/structures/bbox/rotated_boxes.py`

### DMM Model

- [RGB/T data preprocessor](https://github.com/another-0/dmm/blob/main/mmrotate/models/layers/rgbtDetDataPreprocessor.py): Model preprocessor · Prepares paired RGB and thermal inputs. · `mmrotate/models/layers/rgbtDetDataPreprocessor.py`
- [DMM S2ANet detector](https://github.com/another-0/dmm/blob/main/mmrotate/models/detectors/dmm_s2anet.py): Oriented detector · Coordinates feature extraction, fusion, alignment, and prediction. · `mmrotate/models/detectors/dmm_s2anet.py`
- [VMamba backbone](https://github.com/another-0/dmm/blob/main/mmrotate/models/backbones/vmamba/vmamba.py): Backbone · State-space visual feature extractor. · `mmrotate/models/backbones/vmamba/vmamba.py`
- [Selective scan](https://github.com/another-0/dmm/blob/main/mmrotate/models/backbones/vmamba/csms6s.py): CUDA state-space op · VMamba integration backed by selective_scan. · `mmrotate/models/backbones/vmamba/csms6s.py`
- [RGBT Mamba fusion](https://github.com/another-0/dmm/blob/main/mmrotate/models/layers/dmm/rgbtmamba.py): Fusion layer · Disparity-guided multispectral fusion. · `mmrotate/models/layers/dmm/rgbtmamba.py`
- [Oriented dense heads](https://github.com/another-0/dmm/blob/main/mmrotate/models/dense_heads/s2a_head.py): Detection heads · S2A, rotated Retina, and RTMDet head family. · `mmrotate/models/dense_heads/s2a_head.py`
- [Rotated supervision](https://github.com/another-0/dmm/blob/main/mmrotate/models/task_modules/assigners/rotated_atss_assigner.py): Assigner, coder & loss · Assignment, rotated-box decoding, and rotated IoU loss. · `mmrotate/models/task_modules/assigners/rotated_atss_assigner.py`

### Evaluation & Deployment

- [DOTA metrics](https://github.com/another-0/dmm/blob/main/mmrotate/evaluation/metrics/dota_metric.py): Evaluation metric · Scores oriented detections using DOTA and rotated-COCO protocols. · `mmrotate/evaluation/metrics/dota_metric.py`
- [Inference API](https://github.com/another-0/dmm/blob/main/mmrotate/apis/inference.py): Inference API · Single-image and huge-image inference entry boundary. · `mmrotate/apis/inference.py`
- [Large-image patching](https://github.com/another-0/dmm/blob/main/mmrotate/utils/patch/split.py): Patch workflow · Splits large images and merges patch predictions. · `mmrotate/utils/patch/split.py`
- [Local visualizer](https://github.com/another-0/dmm/blob/main/mmrotate/visualization/local_visualizer.py): Visualization · `mmrotate/visualization/local_visualizer.py`
- [TorchServe export](https://github.com/another-0/dmm/blob/main/tools/deployment/mmrotate2torchserve.py): Serving integration · Optional model packaging and request handler integration. · `tools/deployment/mmrotate2torchserve.py`

## Connections

- Training CLI → DMM experiment config: loads
- Test CLI → DMM experiment config: loads
- DMM experiment config → DroneVehicle config: inherits
- DMM experiment config → MMRotate registry: builds through
- DMM experiment config → DMM S2ANet detector: selects
- Dataset preparation → DroneVehicle dataset: produces normalized input for
- DroneVehicle config → DroneVehicle dataset: configures
- DroneVehicle dataset → Load & geometric transforms: feeds samples through
- Load & geometric transforms → Rotated box structures: creates and transforms
- Load & geometric transforms → RGB/T data preprocessor: delivers tensors to
- RGB/T data preprocessor → DMM S2ANet detector: prepares inputs for
- DMM S2ANet detector → VMamba backbone: extracts features with
- VMamba backbone → Selective scan: uses
- DMM S2ANet detector → RGBT Mamba fusion: fuses modalities through
- DMM S2ANet detector → Oriented dense heads: predicts through
- Oriented dense heads → Rotated supervision: trains with
- Rotated supervision → Rotated box structures: consumes oriented targets
- Test CLI → DOTA metrics: evaluates with
- Oriented dense heads → DOTA metrics: emits predictions for
- Inference API → DMM S2ANet detector: runs
- Inference API → Large-image patching: uses for huge images
- Large-image patching → Local visualizer: renders merged results
- DMM S2ANet detector → TorchServe export: optionally packaged for
