# tinyaway/ssf-gnn architecture

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

- Interactive diagram: https://gitdiagram.com/tinyaway/ssf-gnn
- Repository: https://github.com/tinyaway/ssf-gnn

## Overview

SSF-GNN is a research implementation for classifying seven multi-hazard categories from Sentinel-2 imagery. Its documented workflow loads labeled imagery, optionally derives spectral indices, and trains or tests an SSF-GNN that combines segmentation-derived semantic structure with spectral graph reasoning. The README also describes S2MHD as a 169-event dataset. Source excerpts show the dataset, model, and training paths; test.py is documented but unsampled, so its internal behavior is not inferred.

Main entry points: [`model.py`](https://github.com/tinyaway/ssf-gnn/blob/main/model.py) (SSF-GNN classifier), [`PSPNet.py`](https://github.com/tinyaway/ssf-gnn/blob/main/PSPNet.py) (PSP segmentation branch), [`dataset.py`](https://github.com/tinyaway/ssf-gnn/blob/main/dataset.py) (Labeled imagery loader), [`train.py`](https://github.com/tinyaway/ssf-gnn/blob/main/train.py) (Training and validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Imagery and features"]
  node_loader["Labeled imagery loader<br/>[dataset.py]"]
  node_indices["Spectral indices<br/>[Compute_indices.py]"]
end

subgraph group_net["Model components"]
  node_ssfgnn["SSF-GNN classifier<br/>[model.py]"]
  node_segmentation["PSP segmentation branch<br/>[PSPNet.py]"]
  node_semantic_graph["Semantic graph construction<br/>[model.py]"]
  node_spectral_graph["Spectral graph construction<br/>[model.py]"]
  node_graph_reasoning["Dual graph reasoning<br/>[model.py]"]
  node_classifier["Class prediction head<br/>[model.py]"]
  node_vig_encoder["ViG encoder<br/>[ViG.py]"]
  node_efficientnet_encoder["EfficientNet encoder<br/>[efficientnet.py]"]
end

subgraph group_workflow["Training and evaluation"]
  node_trainer["Training and validation<br/>[train.py]"]
  node_tester["Testing entry point<br/>[test.py]"]
end

node_dataset_source(("S2MHD imagery"))

node_dataset_source -->|"provides imagery"| node_loader
node_loader -->|"computes indices"| node_indices
node_trainer -->|"loads batches"| node_loader
node_trainer -->|"trains classifier"| node_ssfgnn
node_dataset_source -.->|"testing data"| node_tester
node_ssfgnn -->|"runs segmentation"| node_segmentation
node_segmentation -->|"uses encoder"| node_vig_encoder
node_segmentation -->|"alternative encoder"| node_efficientnet_encoder
node_ssfgnn -->|"builds semantic graph"| node_semantic_graph
node_ssfgnn -->|"builds spectral graph"| node_spectral_graph
node_ssfgnn -->|"applies graph layers"| node_graph_reasoning
node_ssfgnn -->|"decodes features"| node_classifier

click node_loader "https://github.com/tinyaway/ssf-gnn/blob/main/dataset.py"
click node_indices "https://github.com/tinyaway/ssf-gnn/blob/main/Compute_indices.py"
click node_trainer "https://github.com/tinyaway/ssf-gnn/blob/main/train.py"
click node_tester "https://github.com/tinyaway/ssf-gnn/blob/main/test.py"
click node_ssfgnn "https://github.com/tinyaway/ssf-gnn/blob/main/model.py"
click node_segmentation "https://github.com/tinyaway/ssf-gnn/blob/main/PSPNet.py"
click node_semantic_graph "https://github.com/tinyaway/ssf-gnn/blob/main/model.py"
click node_spectral_graph "https://github.com/tinyaway/ssf-gnn/blob/main/model.py"
click node_graph_reasoning "https://github.com/tinyaway/ssf-gnn/blob/main/model.py"
click node_classifier "https://github.com/tinyaway/ssf-gnn/blob/main/model.py"
click node_vig_encoder "https://github.com/tinyaway/ssf-gnn/blob/main/ViG.py"
click node_efficientnet_encoder "https://github.com/tinyaway/ssf-gnn/blob/main/efficientnet.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_loader,node_indices toneBlue
class node_ssfgnn,node_segmentation,node_semantic_graph,node_spectral_graph,node_graph_reasoning,node_classifier,node_vig_encoder,node_efficientnet_encoder toneAmber
class node_trainer,node_tester toneMint
class node_dataset_source toneIndigo
```

## Components

### Imagery and features

- [Labeled imagery loader](https://github.com/tinyaway/ssf-gnn/blob/main/dataset.py): `dataset.py`
- [Spectral indices](https://github.com/tinyaway/ssf-gnn/blob/main/Compute_indices.py): `Compute_indices.py`

### Model components

- [SSF-GNN classifier](https://github.com/tinyaway/ssf-gnn/blob/main/model.py): `model.py`
- [PSP segmentation branch](https://github.com/tinyaway/ssf-gnn/blob/main/PSPNet.py): `PSPNet.py`
- [Semantic graph construction](https://github.com/tinyaway/ssf-gnn/blob/main/model.py): `model.py`
- [Spectral graph construction](https://github.com/tinyaway/ssf-gnn/blob/main/model.py): `model.py`
- [Dual graph reasoning](https://github.com/tinyaway/ssf-gnn/blob/main/model.py): `model.py`
- [Class prediction head](https://github.com/tinyaway/ssf-gnn/blob/main/model.py): `model.py`
- [ViG encoder](https://github.com/tinyaway/ssf-gnn/blob/main/ViG.py): `ViG.py`
- [EfficientNet encoder](https://github.com/tinyaway/ssf-gnn/blob/main/efficientnet.py): `efficientnet.py`

### Training and evaluation

- [Training and validation](https://github.com/tinyaway/ssf-gnn/blob/main/train.py): `train.py`
- [Testing entry point](https://github.com/tinyaway/ssf-gnn/blob/main/test.py): `test.py`

### Other components

- **S2MHD imagery**

## Connections

- S2MHD imagery → Labeled imagery loader: provides imagery (evidence: `README.md`)
- Labeled imagery loader → Spectral indices: computes indices (evidence: `dataset.py`)
- Training and validation → Labeled imagery loader: loads batches (evidence: `train.py`)
- Training and validation → SSF-GNN classifier: trains classifier (evidence: `train.py`)
- S2MHD imagery → Testing entry point: testing data
- SSF-GNN classifier → PSP segmentation branch: runs segmentation (evidence: `model.py`)
- PSP segmentation branch → ViG encoder: uses encoder (evidence: `PSPNet.py`)
- PSP segmentation branch → EfficientNet encoder: alternative encoder (evidence: `PSPNet.py`)
- SSF-GNN classifier → Semantic graph construction: builds semantic graph (evidence: `model.py`)
- SSF-GNN classifier → Spectral graph construction: builds spectral graph (evidence: `model.py`)
- SSF-GNN classifier → Dual graph reasoning: applies graph layers (evidence: `model.py`)
- SSF-GNN classifier → Class prediction head: decodes features (evidence: `model.py`)
