# murali0127/thermal-runaway-detection-unet architecture

> Architecture diagram of the GitHub repository murali0127/thermal-runaway-detection-unet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/murali0127/thermal-runaway-detection-unet
- Repository: https://github.com/murali0127/thermal-runaway-detection-unet

## Overview

This repository is a U-Net thermal-runaway segmentation project. Its main workflow prepares paired thermal images and masks, trains and evaluates a segmentation model, then runs batch or live inference to produce hotspot masks and metrics. Separate scripts provide prediction plots and Grad-CAM/attention explanations. The README also describes MOSFET-based cooling and isolation, but no implementation is present in the sampled source or tree; that capability is shown as an unverified documented integration. Inference internals are only partially excerpted.

Main entry points: [`src/train.py`](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/train.py) (Training pipeline), [`src/inference.py`](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/inference.py) (Inference engine), [`src/model.py`](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/model.py) (U-Net segmentation), [`src/utils.py`](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py) (Dataset path loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_thermal["Thermal images"]
  node_masks["Ground-truth masks"]
  node_pathload["Dataset path loading<br/>[utils.py]"]
  node_generator["Batch preprocessing<br/>[utils.py]"]
end

subgraph group_learning["Model training"]
  node_trainer["Training pipeline<br/>[train.py]"]
  node_unet["U-Net segmentation<br/>[model.py]"]
  node_loss["Loss and metrics<br/>[utils.py]"]
end

subgraph group_runtime["Inference"]
  node_inference["Inference engine<br/>[inference.py]"]
  node_tflite["TFLite and live inference<br/>[inference.py]"]
  node_response["MOSFET cooling and isolation<br/>[README.md]"]
end

subgraph group_analysis["Evaluation and explanation"]
  node_predictions["Prediction visualizations<br/>[prediction.py]"]
  node_gradcam["Grad-CAM explanations"]
  node_attention["Attention maps<br/>[attention_map.py]"]
  node_metricsout["Metric reports<br/>[metrices.py]"]
  node_artifacts["Saved model and results"]
end

node_operator(("Engineer or operator"))

node_trainer -->|"loads paths"| node_pathload
node_pathload -->|"finds images"| node_thermal
node_pathload -->|"finds masks"| node_masks
node_trainer -->|"builds batches"| node_generator
node_trainer -->|"builds model"| node_unet
node_trainer -->|"compiles with"| node_loss
node_trainer -->|"saves model"| node_artifacts
node_trainer -->|"requests plots"| node_predictions
node_trainer -->|"writes report"| node_metricsout
node_operator -->|"starts training"| node_trainer
node_operator -->|"starts inference"| node_inference
node_thermal -.->|"provides images"| node_inference
node_inference -->|"uses metrics"| node_loss
node_inference -->|"supports conversion"| node_tflite
node_inference -.->|"saves predictions"| node_artifacts
node_unet -.->|"explains activations"| node_gradcam
node_unet -.->|"extracts features"| node_attention
node_unet -.->|"visualizes masks"| node_predictions
node_inference -.->|"triggers mitigation"| node_response

click node_thermal "https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/dataset/images"
click node_masks "https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/dataset/images/dataset/masks"
click node_pathload "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py"
click node_generator "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py"
click node_trainer "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/train.py"
click node_unet "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/model.py"
click node_loss "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py"
click node_inference "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/inference.py"
click node_tflite "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/inference.py"
click node_predictions "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/prediction.py"
click node_gradcam "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/grad-CAM_activation.py"
click node_attention "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/attention_map.py"
click node_metricsout "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Metrices/metrices.py"
click node_artifacts "https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/Result"
click node_response "https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/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_thermal,node_masks,node_pathload,node_generator toneBlue
class node_trainer,node_unet,node_loss toneAmber
class node_inference,node_tflite,node_response toneMint
class node_predictions,node_gradcam,node_attention,node_metricsout,node_artifacts toneRose
class node_operator toneIndigo
```

## Components

### Data preparation

- [Thermal images](https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/dataset/images): `dataset/images`
- [Ground-truth masks](https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/dataset/images/dataset/masks): `dataset/images/dataset/masks`
- [Dataset path loading](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py): `src/utils.py`
- [Batch preprocessing](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py): `src/utils.py`

### Model training

- [Training pipeline](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/train.py): `src/train.py`
- [U-Net segmentation](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/model.py): `src/model.py`
- [Loss and metrics](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/utils.py): `src/utils.py`

### Inference

- [Inference engine](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/inference.py): `src/inference.py`
- [TFLite and live inference](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/src/inference.py): `src/inference.py`
- [MOSFET cooling and isolation](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/README.md): `README.md`

### Evaluation and explanation

- [Prediction visualizations](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/prediction.py): `Result/Predictions/prediction.py`
- [Grad-CAM explanations](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/grad-CAM_activation.py): `Result/Predictions/grad-CAM_activation.py`
- [Attention maps](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Predictions/attention_map.py): `Result/Predictions/attention_map.py`
- [Metric reports](https://github.com/murali0127/thermal-runaway-detection-unet/blob/main/Result/Metrices/metrices.py): `Result/Metrices/metrices.py`
- [Saved model and results](https://github.com/murali0127/thermal-runaway-detection-unet/tree/main/Result): `Result`

### Other components

- **Engineer or operator**

## Connections

- Training pipeline → Dataset path loading: loads paths (evidence: `src/train.py`)
- Dataset path loading → Thermal images: finds images (evidence: `src/utils.py`)
- Dataset path loading → Ground-truth masks: finds masks (evidence: `src/utils.py`)
- Training pipeline → Batch preprocessing: builds batches (evidence: `src/train.py`)
- Training pipeline → U-Net segmentation: builds model (evidence: `src/train.py`)
- Training pipeline → Loss and metrics: compiles with (evidence: `src/train.py`)
- Training pipeline → Saved model and results: saves model (evidence: `src/train.py`)
- Training pipeline → Prediction visualizations: requests plots (evidence: `src/train.py`)
- Training pipeline → Metric reports: writes report (evidence: `src/train.py`)
- Engineer or operator → Training pipeline: starts training (evidence: `README.md`)
- Engineer or operator → Inference engine: starts inference (evidence: `README.md`)
- Thermal images → Inference engine: provides images
- Inference engine → Loss and metrics: uses metrics (evidence: `src/inference.py`)
- Inference engine → TFLite and live inference: supports conversion (evidence: `src/inference.py`)
- Inference engine → Saved model and results: saves predictions
- U-Net segmentation → Grad-CAM explanations: explains activations (evidence: `Result/Predictions/grad-CAM_activation.py`)
- U-Net segmentation → Attention maps: extracts features (evidence: `Result/Predictions/attention_map.py`)
- U-Net segmentation → Prediction visualizations: visualizes masks (evidence: `Result/Predictions/prediction.py`)
- Inference engine → MOSFET cooling and isolation: triggers mitigation (evidence: `README.md`)
