# qazi0/real-time-disaster-management architecture

> Architecture diagram of the GitHub repository qazi0/real-time-disaster-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/qazi0/real-time-disaster-management
- Repository: https://github.com/qazi0/real-time-disaster-management

## Overview

1. This repository is split into two largely independent ML pipelines under `code/`: **disaster detection/classification** and **victim localization/object detection**. Both are centered on aerial imagery for disaster response, but they use different model families, datasets, and deployment paths.

2. The **disaster detection** subsystem (`code/disaster_detection`) is a PyTorch image-classification pipeline built around the **AIDER** dataset. Its purpose is to classify an input aerial image into one of five emergency-response classes: flood, collapsed building, fire, normal, or traffic incident.

3. The classification training path is: `dataloaders/` loads AIDER splits and preprocessing, `model/` defines the network variants, `train.py` trains them, and `weights/` stores the trained checkpoints. Supporting training logic lives in `training_utils/` for argument parsing, config, metrics, meters, early stopping, and training helpers.

4. The main model boundary in disaster detection is between the two custom architectures: **Squeeze ErNET** and **Squeeze ErNET RedConv**. They are improved versions of EmergencyNet-style atrous feature fusion, with shared support code such as `acff.py`, `ernet.py`, `squeeze_ernet.py`, `squeeze_ernet_redconv.py`, and loss helpers like focal loss and label smoothing.

5. The disaster-detection inference/export path is separate from training. `aider-predict.py` performs single-image inference, `real-time-inference.py` runs webcam/stream inference, `generate_onnx.py` exports ONNX models, and `build_tensorrt_model.py` converts models into TensorRT-ready artifacts. Prebuilt ONNX files, TensorRT state dicts, and model summaries are checked in to support deployment and comparison.

6. Performance evaluation is also first-class in the classification pipeline. `evaluate-classification-metrics.py` measures accuracy, F1, and FPS for both PyTorch and TensorRT variants, while `calculate-power-usage.py` captures power traces on Jetson TX2 and stores plots under `power_usage_plots/`. This makes the deployment story not just accuracy-driven, but also latency- and energy-driven.

7. The **victim localization** subsystem (`code/victim_localization`) is a separate object-detection stack. It focuses on detecting people and vehicles in aerial images using the **ODDER** dataset and supports multiple YOLO generations: YOLOv3, YOLOv4, and YOLOv5.

8. Within victim localization, the repo contains three parallel model families. `yolov3/` and `yolov5/` are training/detection codebases with their own configs, datasets, and weights; `tensorrt_inference/` wraps optimized inference for YOLO models using TensorRT. Each family has its own runtime and artifact format, so they should be treated as separate deployment targets in an architecture diagram.

9. The YOLO pipelines follow a similar flow: dataset definitions and annotations under `data/` or `dataset/`, model definitions in `models/` or config files in `cfg/`, training via `train.py`, evaluation via `test.py`, and inference via `detect.py`. Pretrained `.weights`, `.pt`, ONNX exports, and TensorRT engine files are stored alongside the code to support offline deployment.

10. The TensorRT object-detection path is especially important architecturally. Under `victim_localization/tensorrt_inference/`, there are CUDA/TensorRT plugin components, calibration caches, ONNX conversion scripts, and a compiled YOLO layer implementation. This indicates a deployment boundary where the YOLO graph is exported, optimized, calibrated, and then executed with GPU-accelerated plugins.

11. Dataset handling is a major boundary in both subsystems. The classification side uses CSV-defined AIDER splits in `dataloaders/`, while the detection side uses image/label directory layouts and YOLO-formatted text annotations. The repo also includes scripts and files for generating or verifying splits, which are part of the data preparation layer rather than the model layer.

12. Operationally, the repository targets both development and edge deployment. It references Ubuntu x86_64 and NVIDIA Jetson TX2, and includes TensorRT, CUDA, and PyCUDA-related assets where acceleration matters. That means the architecture is not just “train a model”; it is “train, export, optimize, evaluate, and deploy” across CPU/GPU and embedded inference environments.

13. For a diagram, the cleanest high-level separation is: **AIDER classification pipeline** on one side and **ODDER/YOLO victim-localization pipeline** on the other, with each pipeline flowing from dataset preparation to training to exported artifacts to optimized inference. Shared concerns like metrics, power analysis, and pretrained artifact storage sit at the edges of both pipelines rather than in the core model logic.

Main entry points: [`code/victim_localization/tensorrt_inference/trt_yolo.py`](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/trt_yolo.py) (TensorRT detect), [`code/disaster_detection/train.py`](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/train.py) (Train loop), [`code/disaster_detection/aider-predict.py`](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/aider-predict.py) (Inference tools), [`code/disaster_detection/model`](https://github.com/qazi0/real-time-disaster-management/tree/dev/code/disaster_detection/model) (Classifiers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_disaster["Disaster detection"]
  node_n_aider_data["AIDER splits<br/>csv dataset<br/>[aider_train.csv]"]
  node_n_aider_loader["Data loader<br/>pytorch dataloader<br/>[aider.py]"]
  node_n_dd_models["Classifiers<br/>model family"]
  node_n_dd_train["Train loop<br/>trainer<br/>[train.py]"]
  node_n_dd_weights[("PyTorch weights<br/>checkpoints<br/>[Squeeze-ernet.pt]")]
  node_n_dd_infer["Inference tools<br/>deploy scripts<br/>[aider-predict.py]"]
  node_n_dd_artifacts[("Exported models<br/>onnx/trt artifacts<br/>[ernet.onnx]")]
  node_n_dd_utils["Training utils<br/>helpers"]
end

subgraph group_grp_victim["Victim localization"]
  node_n_vl_data3["YOLOv3 data<br/>annotations<br/>[aider.data]"]
  node_n_vl_y3["YOLOv3 stack<br/>detector runtime<br/>[train.py]"]
  node_n_vl_y5["YOLOv5 stack<br/>detector runtime<br/>[train.py]"]
  node_n_vl_data5["YOLOv5 data<br/>dataset<br/>[aider.yaml]"]
  node_n_vl_trt["TensorRT detect<br/>optimized inference<br/>[trt_yolo.py]"]
  node_n_vl_plugins["CUDA plugins<br/>gpu kernels<br/>[yolo_layer.cu]"]
  node_n_vl_engines[("Engines<br/>onnx/trt artifacts")]
  node_n_vl_weights[("YOLO weights<br/>pretrained weights")]
end

subgraph group_grp_shared["Shared assets"]
  node_n_shared_docs["Docs & deliverables<br/>project outputs<br/>[README.md]"]
end

node_n_aider_data -->|"feeds"| node_n_aider_loader
node_n_aider_loader -->|"trains"| node_n_dd_train
node_n_dd_utils -->|"supports"| node_n_dd_train
node_n_dd_train -->|"fits"| node_n_dd_models
node_n_dd_models -->|"produces"| node_n_dd_weights
node_n_dd_models -->|"serves"| node_n_dd_infer
node_n_dd_train -->|"exports"| node_n_dd_artifacts
node_n_dd_infer -->|"consumes"| node_n_dd_artifacts
node_n_dd_artifacts -->|"evaluates"| node_n_dd_infer
node_n_dd_infer -->|"documented by"| node_n_shared_docs
node_n_vl_data3 -->|"feeds"| node_n_vl_y3
node_n_vl_data5 -->|"feeds"| node_n_vl_y5
node_n_vl_y3 -->|"produces"| node_n_vl_weights
node_n_vl_y5 -->|"produces"| node_n_vl_weights
node_n_vl_y3 -->|"exports"| node_n_vl_trt
node_n_vl_y5 -->|"exports"| node_n_vl_trt
node_n_vl_trt -->|"uses"| node_n_vl_plugins
node_n_vl_trt -->|"runs"| node_n_vl_engines
node_n_vl_plugins -->|"enables"| node_n_vl_engines
node_n_vl_trt -->|"documented by"| node_n_shared_docs

click node_n_aider_data "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/dataloaders/aider_train.csv"
click node_n_aider_loader "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/dataloaders/aider.py"
click node_n_dd_models "https://github.com/qazi0/real-time-disaster-management/tree/dev/code/disaster_detection/model"
click node_n_dd_train "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/train.py"
click node_n_dd_weights "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/weights/Squeeze-ernet.pt"
click node_n_dd_infer "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/aider-predict.py"
click node_n_dd_artifacts "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/onnx/ernet.onnx"
click node_n_dd_utils "https://github.com/qazi0/real-time-disaster-management/tree/dev/code/disaster_detection/training_utils"
click node_n_vl_data3 "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/data/aider.data"
click node_n_vl_y3 "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/train.py"
click node_n_vl_y5 "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov5/train.py"
click node_n_vl_data5 "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov5/data/aider.yaml"
click node_n_vl_trt "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/trt_yolo.py"
click node_n_vl_plugins "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/plugins/yolo_layer.cu"
click node_n_vl_engines "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/yolo/engines/yolov4-tiny-aider-416.trt"
click node_n_vl_weights "https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/weights/yolov3-tiny-aider-416.weights"
click node_n_shared_docs "https://github.com/qazi0/real-time-disaster-management/blob/dev/README.md"

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_n_aider_data,node_n_aider_loader,node_n_dd_models,node_n_dd_train,node_n_dd_weights,node_n_dd_infer,node_n_dd_artifacts,node_n_dd_utils toneBlue
class node_n_vl_data3,node_n_vl_y3,node_n_vl_y5,node_n_vl_data5,node_n_vl_trt,node_n_vl_plugins,node_n_vl_engines,node_n_vl_weights toneAmber
class node_n_shared_docs toneMint
```

## Components

### Disaster detection

AIDER-based image classification pipeline for aerial disaster assessment.

- [AIDER splits](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/dataloaders/aider_train.csv): csv dataset · CSV-defined train/val/test splits and labels for disaster classification. · `code/disaster_detection/dataloaders/aider_train.csv`
- [Data loader](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/dataloaders/aider.py): pytorch dataloader · Loads AIDER samples and preprocessing for classification training. · `code/disaster_detection/dataloaders/aider.py`
- [Classifiers](https://github.com/qazi0/real-time-disaster-management/tree/dev/code/disaster_detection/model): model family · Emergency-response classifiers, centered on Squeeze ErNET variants and ERNet. · `code/disaster_detection/model`
- [Train loop](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/train.py): trainer · Training entrypoint and utilities for classification experiments. · `code/disaster_detection/train.py`
- [PyTorch weights](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/weights/Squeeze-ernet.pt): checkpoints · Saved classification checkpoints for ERNet and Squeeze ErNET variants. · `code/disaster_detection/weights/Squeeze-ernet.pt`
- [Inference tools](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/aider-predict.py): deploy scripts · Single-image, realtime, ONNX export, TensorRT build, and metric/power evaluation scripts. · `code/disaster_detection/aider-predict.py`
- [Exported models](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/disaster_detection/onnx/ernet.onnx): onnx/trt artifacts · ONNX exports, TensorRT state dicts, model summaries, and power traces for deployment comparison. · `code/disaster_detection/onnx/ernet.onnx`
- [Training utils](https://github.com/qazi0/real-time-disaster-management/tree/dev/code/disaster_detection/training_utils): helpers · Args, config, metrics, meters, early stopping, and training helpers. · `code/disaster_detection/training_utils`

### Victim localization

ODDER/YOLO object detection pipeline for people and vehicle localization.

- [YOLOv3 data](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/data/aider.data): annotations · YOLOv3-style dataset definitions, class names, and image/label splits. · `code/victim_localization/yolov3/data/aider.data`
- [YOLOv3 stack](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/train.py): detector runtime · YOLOv3 training, testing, detection, and model definitions. · `code/victim_localization/yolov3/train.py`
- [YOLOv5 stack](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov5/train.py): detector runtime · YOLOv5 training, testing, detection, and model definitions. · `code/victim_localization/yolov5/train.py`
- [YOLOv5 data](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov5/data/aider.yaml): dataset · YOLOv5 dataset layouts, YAML config, and labels cache. · `code/victim_localization/yolov5/data/aider.yaml`
- [TensorRT detect](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/trt_yolo.py): optimized inference · TensorRT wrapper, YOLO plugins, calibration caches, and engine generation for fast detection. · `code/victim_localization/tensorrt_inference/trt_yolo.py`
- [CUDA plugins](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/plugins/yolo_layer.cu): gpu kernels · Custom YOLO layer implementation and plugin build support used by TensorRT inference. · `code/victim_localization/tensorrt_inference/plugins/yolo_layer.cu`
- [Engines](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/tensorrt_inference/yolo/engines/yolov4-tiny-aider-416.trt): onnx/trt artifacts · ONNX models, TRT engines, and calibration caches for optimized YOLO deployment. · `code/victim_localization/tensorrt_inference/yolo/engines/yolov4-tiny-aider-416.trt`
- [YOLO weights](https://github.com/qazi0/real-time-disaster-management/blob/dev/code/victim_localization/yolov3/weights/yolov3-tiny-aider-416.weights): pretrained weights · Stored detector weights for YOLOv3 and YOLOv5 variants. · `code/victim_localization/yolov3/weights/yolov3-tiny-aider-416.weights`

### Shared assets

Checked-in artifacts and project-level deliverables used across pipelines.

- [Docs & deliverables](https://github.com/qazi0/real-time-disaster-management/blob/dev/README.md): project outputs · Repository-level README, report, and presentation artifacts. · `README.md`

## Connections

- AIDER splits → Data loader: feeds · CSV splits are loaded and preprocessed for training.
- Data loader → Train loop: trains · Batched samples drive classifier optimization.
- Training utils → Train loop: supports · Shared training helpers and metrics are used by the trainer.
- Train loop → Classifiers: fits · Training selects among ERNet and Squeeze ErNET variants.
- Classifiers → PyTorch weights: produces · Training outputs checkpoint files.
- Classifiers → Inference tools: serves · Inference scripts load the classifier architectures.
- Train loop → Exported models: exports · Models are exported to ONNX and TensorRT-friendly artifacts.
- Inference tools → Exported models: consumes · Runtime scripts use exported models and deployment artifacts.
- Exported models → Inference tools: evaluates · Evaluation compares PyTorch and TensorRT performance.
- Inference tools → Docs & deliverables: documented by · Usage and results are captured in project documentation.
- YOLOv3 data → YOLOv3 stack: feeds · YOLOv3 annotations and config drive training and detection.
- YOLOv5 data → YOLOv5 stack: feeds · YOLOv5 dataset layout and YAML config drive training and detection.
- YOLOv3 stack → YOLO weights: produces · YOLOv3 training outputs detector weights.
- YOLOv5 stack → YOLO weights: produces · YOLOv5 training outputs detector weights.
- YOLOv3 stack → TensorRT detect: exports · YOLOv3 models can be converted into optimized inference paths.
- YOLOv5 stack → TensorRT detect: exports · YOLOv5 models can be converted into optimized inference paths.
- TensorRT detect → CUDA plugins: uses · TensorRT inference relies on custom CUDA plugins.
- TensorRT detect → Engines: runs · Optimized inference executes serialized engines and calibration artifacts.
- CUDA plugins → Engines: enables · Compiled plugin layers support engine execution.
- TensorRT detect → Docs & deliverables: documented by · Deployment and setup are captured in repository documentation.
