# zhasion/rsar architecture

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

- Interactive diagram: https://gitdiagram.com/zhasion/rsar
- Repository: https://github.com/zhasion/rsar

## Overview

RSAR is a rotated-object-detection research repository built on MMRotate, with its distinctive contribution being the Unit Cycle Resolver (UCR) for weakly supervised angle prediction and the RSAR SAR benchmark. The principal workflow configures a detector and dataset, trains it, then evaluates or runs inference on images; huge-image inference additionally slices images and merges patch results. The README documents optical-dataset experiments and full dataset preparation. Sampled source supports the inference and data/model primitives; several broader training and evaluation links are documented rather than verified in source excerpts.

Main entry points: [`mmrotate/models/detectors`](https://github.com/zhasion/rsar/tree/main/mmrotate/models/detectors) (Detectors), [`mmrotate/apis/inference.py`](https://github.com/zhasion/rsar/blob/main/mmrotate/apis/inference.py) (Image Inference), [`tools/train.py`](https://github.com/zhasion/rsar/blob/main/tools/train.py) (Training Runner), [`configs`](https://github.com/zhasion/rsar/tree/main/configs) (Experiment Configs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training Workflow"]
  node_configs["Experiment Configs"]
  node_trainer["Training Runner<br/>[train.py]"]
end

subgraph group_data["Data and Evaluation"]
  node_source_data[("SAR and Optical Data")]
  node_datasets["Dataset Loaders"]
  node_transforms["Image Transforms"]
  node_metrics["Detection Metrics"]
end

subgraph group_models["Detection Models"]
  node_backbone["Feature Backbones"]
  node_detectors["Detectors"]
  node_heads["Detection Heads"]
  node_roi_heads["ROI Heads"]
  node_losses["Detection Losses"]
  node_box_ops["Rotated Box Types"]
  node_angle_ucr["UCR Resolver"]
end

subgraph group_serving["Inference and Results"]
  node_inference["Image Inference<br/>[inference.py]"]
  node_patch_inference["Huge-Image Patches<br/>[inference.py]"]
  node_visualization["Detection Visualization"]
  node_torchserve["TorchServe Handler"]
end

node_researcher(("Researcher"))
node_image_user(("Image User"))

node_researcher -->|"selects experiment"| node_configs
node_configs -->|"configures training"| node_trainer
node_source_data -->|"provides annotations"| node_datasets
node_datasets -->|"transforms samples"| node_transforms
node_trainer -->|"loads batches"| node_datasets
node_trainer -->|"trains detector"| node_detectors
node_configs -.->|"enables UCR"| node_angle_ucr
node_detectors -->|"extracts features"| node_backbone
node_detectors -->|"predicts boxes"| node_heads
node_detectors -.->|"refines proposals"| node_roi_heads
node_heads -->|"computes objectives"| node_losses
node_heads -->|"represents boxes"| node_box_ops
node_angle_ucr -->|"constrains angles"| node_losses
node_trainer -->|"evaluates predictions"| node_metrics
node_image_user -->|"submits images"| node_inference
node_inference -->|"runs prediction"| node_detectors
node_inference -.->|"dispatches patches"| node_patch_inference
node_patch_inference -->|"infers patches"| node_detectors
node_patch_inference -->|"merges detections"| node_box_ops
node_torchserve -->|"calls inference"| node_inference
node_inference -.->|"renders results"| node_visualization
node_metrics -->|"reports accuracy"| node_researcher

click node_configs "https://github.com/zhasion/rsar/tree/main/configs"
click node_trainer "https://github.com/zhasion/rsar/blob/main/tools/train.py"
click node_datasets "https://github.com/zhasion/rsar/tree/main/mmrotate/datasets"
click node_transforms "https://github.com/zhasion/rsar/tree/main/mmrotate/datasets/transforms"
click node_metrics "https://github.com/zhasion/rsar/tree/main/mmrotate/evaluation"
click node_backbone "https://github.com/zhasion/rsar/tree/main/mmrotate/models/backbones"
click node_detectors "https://github.com/zhasion/rsar/tree/main/mmrotate/models/detectors"
click node_heads "https://github.com/zhasion/rsar/tree/main/mmrotate/models/dense_heads"
click node_roi_heads "https://github.com/zhasion/rsar/tree/main/mmrotate/models/roi_heads"
click node_losses "https://github.com/zhasion/rsar/tree/main/mmrotate/models/losses"
click node_box_ops "https://github.com/zhasion/rsar/tree/main/mmrotate/structures/bbox"
click node_angle_ucr "https://github.com/zhasion/rsar/blob/main/mmrotate/models/losses/h2rbox_v2_consistency_loss.py"
click node_inference "https://github.com/zhasion/rsar/blob/main/mmrotate/apis/inference.py"
click node_patch_inference "https://github.com/zhasion/rsar/blob/main/mmrotate/apis/inference.py"
click node_visualization "https://github.com/zhasion/rsar/tree/main/mmrotate/visualization"
click node_torchserve "https://github.com/zhasion/rsar/blob/main/tools/deployment/mmrotate_handler.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_configs,node_trainer,node_image_user toneBlue
class node_source_data,node_datasets,node_transforms,node_metrics toneAmber
class node_backbone,node_detectors,node_heads,node_roi_heads,node_losses,node_box_ops,node_angle_ucr toneMint
class node_inference,node_patch_inference,node_visualization,node_torchserve toneRose
class node_researcher toneIndigo
```

## Components

### Training Workflow

- [Experiment Configs](https://github.com/zhasion/rsar/tree/main/configs): `configs`
- [Training Runner](https://github.com/zhasion/rsar/blob/main/tools/train.py): `tools/train.py`

### Data and Evaluation

- **SAR and Optical Data**
- [Dataset Loaders](https://github.com/zhasion/rsar/tree/main/mmrotate/datasets): `mmrotate/datasets`
- [Image Transforms](https://github.com/zhasion/rsar/tree/main/mmrotate/datasets/transforms): `mmrotate/datasets/transforms`
- [Detection Metrics](https://github.com/zhasion/rsar/tree/main/mmrotate/evaluation): `mmrotate/evaluation`

### Detection Models

- [Feature Backbones](https://github.com/zhasion/rsar/tree/main/mmrotate/models/backbones): `mmrotate/models/backbones`
- [Detectors](https://github.com/zhasion/rsar/tree/main/mmrotate/models/detectors): `mmrotate/models/detectors`
- [Detection Heads](https://github.com/zhasion/rsar/tree/main/mmrotate/models/dense_heads): `mmrotate/models/dense_heads`
- [ROI Heads](https://github.com/zhasion/rsar/tree/main/mmrotate/models/roi_heads): `mmrotate/models/roi_heads`
- [Detection Losses](https://github.com/zhasion/rsar/tree/main/mmrotate/models/losses): `mmrotate/models/losses`
- [Rotated Box Types](https://github.com/zhasion/rsar/tree/main/mmrotate/structures/bbox): `mmrotate/structures/bbox`
- [UCR Resolver](https://github.com/zhasion/rsar/blob/main/mmrotate/models/losses/h2rbox_v2_consistency_loss.py): `mmrotate/models/losses/h2rbox_v2_consistency_loss.py`

### Inference and Results

- [Image Inference](https://github.com/zhasion/rsar/blob/main/mmrotate/apis/inference.py): `mmrotate/apis/inference.py`
- [Huge-Image Patches](https://github.com/zhasion/rsar/blob/main/mmrotate/apis/inference.py): `mmrotate/apis/inference.py`
- [Detection Visualization](https://github.com/zhasion/rsar/tree/main/mmrotate/visualization): `mmrotate/visualization`
- [TorchServe Handler](https://github.com/zhasion/rsar/blob/main/tools/deployment/mmrotate_handler.py): `tools/deployment/mmrotate_handler.py`

### Other components

- **Researcher**
- **Image User**

## Connections

- Researcher → Experiment Configs: selects experiment
- Experiment Configs → Training Runner: configures training
- SAR and Optical Data → Dataset Loaders: provides annotations
- Dataset Loaders → Image Transforms: transforms samples
- Training Runner → Dataset Loaders: loads batches
- Training Runner → Detectors: trains detector
- Experiment Configs → UCR Resolver: enables UCR
- Detectors → Feature Backbones: extracts features
- Detectors → Detection Heads: predicts boxes
- Detectors → ROI Heads: refines proposals
- Detection Heads → Detection Losses: computes objectives
- Detection Heads → Rotated Box Types: represents boxes
- UCR Resolver → Detection Losses: constrains angles
- Training Runner → Detection Metrics: evaluates predictions
- Image User → Image Inference: submits images
- Image Inference → Detectors: runs prediction
- Image Inference → Huge-Image Patches: dispatches patches
- Huge-Image Patches → Detectors: infers patches
- Huge-Image Patches → Rotated Box Types: merges detections
- TorchServe Handler → Image Inference: calls inference
- Image Inference → Detection Visualization: renders results
- Detection Metrics → Researcher: reports accuracy
