# zhangjc-2k/ssr architecture

> Architecture diagram of the GitHub repository zhangjc-2k/ssr, 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/zhangjc-2k/ssr
- Repository: https://github.com/zhangjc-2k/ssr

## Overview

This repository implements spectral snapshot reconstruction: spectral image scenes and a coded mask are converted into a compressed measurement, then a learned SSR network reconstructs the hyperspectral image. The documented workflow includes model training, standard and pretrained inference, and Matlab PSNR/SSIM evaluation. The sampled training code confirms dataset preparation, model calls, and checkpoint writes; test scripts and metric internals were not sampled, so their implementation links are omitted or marked unverified.

Main entry points: [`Train.py`](https://github.com/zhangjc-2k/ssr/blob/main/Train.py) (Model training), [`Dataset.py`](https://github.com/zhangjc-2k/ssr/blob/main/Dataset.py) (Measurement samples), [`Model.py`](https://github.com/zhangjc-2k/ssr/blob/main/Model.py) (SSR reconstruction net), [`Test.py`](https://github.com/zhangjc-2k/ssr/blob/main/Test.py) (Standard inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Inputs and preparation"]
  node_train_scenes[("CAVE scenes")]
  node_test_scenes[("Test scenes")]
  node_mask["Coded mask<br/>[mask_256_28.mat]"]
  node_scene_loader["Scene loading<br/>[Utils.py]"]
  node_sample_builder["Measurement samples<br/>[Dataset.py]"]
  node_shift_ops["Shift operations<br/>[Utils.py]"]
end

subgraph group_model["Reconstruction model"]
  node_ssr_network["SSR reconstruction net<br/>[Model.py]"]
end

subgraph group_run["Training and inference"]
  node_trainer["Model training<br/>[Train.py]"]
  node_train_checkpoint[("Training checkpoints")]
  node_standard_test["Standard inference<br/>[Test.py]"]
  node_pretrained_test["Pretrained inference<br/>[Test_pretrain.py]"]
  node_pretrained_weights[("Pretrained weights")]
end

subgraph group_evaluation["Evaluation and outputs"]
  node_results[("Reconstruction results")]
  node_metrics["PSNR SSIM metrics<br/>[cal_psnr_ssim.m]"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts training"| node_trainer
node_researcher -->|"starts testing"| node_standard_test
node_researcher -->|"starts testing"| node_pretrained_test
node_train_scenes -->|"loads scenes"| node_scene_loader
node_scene_loader -->|"provides HSI"| node_trainer
node_train_scenes -.->|"samples patches"| node_sample_builder
node_mask -->|"loads mask"| node_sample_builder
node_sample_builder -->|"shifts mask data"| node_shift_ops
node_trainer -->|"builds batches"| node_sample_builder
node_trainer -->|"trains model"| node_ssr_network
node_sample_builder -->|"provides measurements"| node_ssr_network
node_trainer -->|"writes weights"| node_train_checkpoint
node_train_checkpoint -->|"resumes weights"| node_trainer
node_test_scenes -->|"supplies test data"| node_standard_test
node_standard_test -.->|"runs inference"| node_ssr_network
node_pretrained_weights -->|"loads weights"| node_pretrained_test
node_pretrained_test -.->|"runs inference"| node_ssr_network
node_ssr_network -.->|"produces reconstructions"| node_results
node_results -->|"evaluates results"| node_metrics

click node_train_scenes "https://github.com/zhangjc-2k/ssr/tree/main/CAVE_1024_28"
click node_test_scenes "https://github.com/zhangjc-2k/ssr/tree/main/Test_data"
click node_mask "https://github.com/zhangjc-2k/ssr/blob/main/mask_256_28.mat"
click node_scene_loader "https://github.com/zhangjc-2k/ssr/blob/main/Utils.py"
click node_sample_builder "https://github.com/zhangjc-2k/ssr/blob/main/Dataset.py"
click node_shift_ops "https://github.com/zhangjc-2k/ssr/blob/main/Utils.py"
click node_ssr_network "https://github.com/zhangjc-2k/ssr/blob/main/Model.py"
click node_trainer "https://github.com/zhangjc-2k/ssr/blob/main/Train.py"
click node_train_checkpoint "https://github.com/zhangjc-2k/ssr/tree/main/Checkpoint"
click node_standard_test "https://github.com/zhangjc-2k/ssr/blob/main/Test.py"
click node_pretrained_test "https://github.com/zhangjc-2k/ssr/blob/main/Test_pretrain.py"
click node_pretrained_weights "https://github.com/zhangjc-2k/ssr/tree/main/Checkpoint_pretrain"
click node_results "https://github.com/zhangjc-2k/ssr/tree/main/Result"
click node_metrics "https://github.com/zhangjc-2k/ssr/blob/main/cal_psnr_ssim.m"

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_scenes,node_test_scenes,node_mask,node_scene_loader,node_sample_builder,node_shift_ops toneBlue
class node_ssr_network toneAmber
class node_trainer,node_train_checkpoint,node_standard_test,node_pretrained_test,node_pretrained_weights toneMint
class node_results,node_metrics toneRose
class node_researcher toneIndigo
```

## Components

### Inputs and preparation

- [CAVE scenes](https://github.com/zhangjc-2k/ssr/tree/main/CAVE_1024_28): `CAVE_1024_28`
- [Test scenes](https://github.com/zhangjc-2k/ssr/tree/main/Test_data): `Test_data`
- [Coded mask](https://github.com/zhangjc-2k/ssr/blob/main/mask_256_28.mat): `mask_256_28.mat`
- [Scene loading](https://github.com/zhangjc-2k/ssr/blob/main/Utils.py): `Utils.py`
- [Measurement samples](https://github.com/zhangjc-2k/ssr/blob/main/Dataset.py): `Dataset.py`
- [Shift operations](https://github.com/zhangjc-2k/ssr/blob/main/Utils.py): `Utils.py`

### Reconstruction model

- [SSR reconstruction net](https://github.com/zhangjc-2k/ssr/blob/main/Model.py): `Model.py`

### Training and inference

- [Model training](https://github.com/zhangjc-2k/ssr/blob/main/Train.py): `Train.py`
- [Training checkpoints](https://github.com/zhangjc-2k/ssr/tree/main/Checkpoint): `Checkpoint`
- [Standard inference](https://github.com/zhangjc-2k/ssr/blob/main/Test.py): `Test.py`
- [Pretrained inference](https://github.com/zhangjc-2k/ssr/blob/main/Test_pretrain.py): `Test_pretrain.py`
- [Pretrained weights](https://github.com/zhangjc-2k/ssr/tree/main/Checkpoint_pretrain): `Checkpoint_pretrain`

### Evaluation and outputs

- [Reconstruction results](https://github.com/zhangjc-2k/ssr/tree/main/Result): `Result`
- [PSNR SSIM metrics](https://github.com/zhangjc-2k/ssr/blob/main/cal_psnr_ssim.m): `cal_psnr_ssim.m`

### Other components

- **Researcher**

## Connections

- Researcher → Model training: starts training (evidence: `README.md`)
- Researcher → Standard inference: starts testing (evidence: `README.md`)
- Researcher → Pretrained inference: starts testing (evidence: `README.md`)
- CAVE scenes → Scene loading: loads scenes (evidence: `Utils.py`)
- Scene loading → Model training: provides HSI (evidence: `Train.py`)
- CAVE scenes → Measurement samples: samples patches
- Coded mask → Measurement samples: loads mask (evidence: `Dataset.py`)
- Measurement samples → Shift operations: shifts mask data (evidence: `Dataset.py`)
- Model training → Measurement samples: builds batches (evidence: `Train.py`)
- Model training → SSR reconstruction net: trains model (evidence: `Train.py`)
- Measurement samples → SSR reconstruction net: provides measurements (evidence: `Train.py`)
- Model training → Training checkpoints: writes weights (evidence: `Train.py`)
- Training checkpoints → Model training: resumes weights (evidence: `Train.py`)
- Test scenes → Standard inference: supplies test data (evidence: `README.md`)
- Standard inference → SSR reconstruction net: runs inference
- Pretrained weights → Pretrained inference: loads weights (evidence: `README.md`)
- Pretrained inference → SSR reconstruction net: runs inference
- SSR reconstruction net → Reconstruction results: produces reconstructions
- Reconstruction results → PSNR SSIM metrics: evaluates results (evidence: `README.md`)
