# lzlsxs/hypersc architecture

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

- Interactive diagram: https://gitdiagram.com/lzlsxs/hypersc
- Repository: https://github.com/lzlsxs/hypersc

## Overview

This repository implements exemplar-free lifelong hyperspectral-image classification: a configured run prepares spectral-spatial patches, learns classes in successive tasks, and evaluates accumulated class predictions. The main orchestration and dataset path are visible in the sampled source; the README identifies model inversion and spectral consistency as core capabilities, while the partial learner excerpt shows stored feature statistics. Training details and some subsystem wiring are omitted from the excerpts, so the graph does not infer their internal call sequence.

Main entry points: [`models/hyperinversion.py`](https://github.com/lzlsxs/hypersc/blob/main/models/hyperinversion.py) (Hyper-inversion learner), [`trainer.py`](https://github.com/lzlsxs/hypersc/blob/main/trainer.py) (Task orchestration), [`utils/inc_net.py`](https://github.com/lzlsxs/hypersc/blob/main/utils/inc_net.py) (Incremental network), [`main.py`](https://github.com/lzlsxs/hypersc/blob/main/main.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Run and Data"]
  node_configs["Dataset configs"]
  node_entry["CLI entry<br/>[main.py]"]
  node_trainer["Task orchestration<br/>[trainer.py]"]
  node_data["Task data manager<br/>[data_manager.py]"]
  node_preprocess["HSI preprocessing<br/>[preprocess.py]"]
end

subgraph group_learning["Incremental Learning"]
  node_factory["Model factory<br/>[factory.py]"]
  node_learner["Hyper-inversion learner<br/>[hyperinversion.py]"]
  node_base["Learner lifecycle<br/>[base.py]"]
  node_stats[("Spectral statistics<br/>[hyperinversion.py]")]
end

subgraph group_network["Model Architecture"]
  node_network["Incremental network<br/>[inc_net.py]"]
  node_lsga["LSGA backbone<br/>[lsga.py]"]
  node_resnet["HSI ResNet<br/>[resnet_hsi.py]"]
  node_heads["Incremental heads<br/>[linears.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Accuracy metrics<br/>[toolkit.py]"]
  node_predictions["Task predictions"]
end

node_user(("Experiment runner"))
node_hsi["HSI dataset files"]

node_user -->|"starts run"| node_entry
node_user -->|"selects dataset"| node_configs
node_configs -->|"configures"| node_entry
node_entry -->|"calls train"| node_trainer
node_trainer -->|"builds tasks"| node_data
node_data -->|"prepares samples"| node_preprocess
node_preprocess -->|"reads dataset"| node_hsi
node_trainer -->|"requests model"| node_factory
node_factory -->|"creates learner"| node_learner
node_trainer -->|"runs task lifecycle"| node_learner
node_learner -->|"requests task sets"| node_data
node_learner -->|"inherits lifecycle"| node_base
node_learner -->|"uses classifier"| node_network
node_learner -->|"stores statistics"| node_stats
node_network -.->|"selects backbone"| node_lsga
node_network -.->|"selects backbone"| node_resnet
node_network -->|"uses heads"| node_heads
node_learner -->|"evaluates scores"| node_metrics
node_learner -->|"produces predictions"| node_predictions
node_metrics -->|"scores predictions"| node_predictions

click node_configs "https://github.com/lzlsxs/hypersc/tree/main/configs"
click node_entry "https://github.com/lzlsxs/hypersc/blob/main/main.py"
click node_trainer "https://github.com/lzlsxs/hypersc/blob/main/trainer.py"
click node_data "https://github.com/lzlsxs/hypersc/blob/main/utils/data_manager.py"
click node_preprocess "https://github.com/lzlsxs/hypersc/blob/main/utils/preprocess.py"
click node_factory "https://github.com/lzlsxs/hypersc/blob/main/utils/factory.py"
click node_learner "https://github.com/lzlsxs/hypersc/blob/main/models/hyperinversion.py"
click node_base "https://github.com/lzlsxs/hypersc/blob/main/models/base.py"
click node_stats "https://github.com/lzlsxs/hypersc/blob/main/models/hyperinversion.py"
click node_network "https://github.com/lzlsxs/hypersc/blob/main/utils/inc_net.py"
click node_lsga "https://github.com/lzlsxs/hypersc/blob/main/convs/lsga.py"
click node_resnet "https://github.com/lzlsxs/hypersc/blob/main/convs/resnet_hsi.py"
click node_heads "https://github.com/lzlsxs/hypersc/blob/main/convs/linears.py"
click node_metrics "https://github.com/lzlsxs/hypersc/blob/main/utils/toolkit.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_entry,node_trainer,node_data,node_preprocess toneBlue
class node_factory,node_learner,node_base,node_stats toneAmber
class node_network,node_lsga,node_resnet,node_heads toneMint
class node_metrics,node_predictions toneRose
class node_user,node_hsi toneIndigo
```

## Components

### Run and Data

- [Dataset configs](https://github.com/lzlsxs/hypersc/tree/main/configs): `configs`
- [CLI entry](https://github.com/lzlsxs/hypersc/blob/main/main.py): `main.py`
- [Task orchestration](https://github.com/lzlsxs/hypersc/blob/main/trainer.py): `trainer.py`
- [Task data manager](https://github.com/lzlsxs/hypersc/blob/main/utils/data_manager.py): `utils/data_manager.py`
- [HSI preprocessing](https://github.com/lzlsxs/hypersc/blob/main/utils/preprocess.py): `utils/preprocess.py`

### Incremental Learning

- [Model factory](https://github.com/lzlsxs/hypersc/blob/main/utils/factory.py): `utils/factory.py`
- [Hyper-inversion learner](https://github.com/lzlsxs/hypersc/blob/main/models/hyperinversion.py): `models/hyperinversion.py`
- [Learner lifecycle](https://github.com/lzlsxs/hypersc/blob/main/models/base.py): `models/base.py`
- [Spectral statistics](https://github.com/lzlsxs/hypersc/blob/main/models/hyperinversion.py): `models/hyperinversion.py`

### Model Architecture

- [Incremental network](https://github.com/lzlsxs/hypersc/blob/main/utils/inc_net.py): `utils/inc_net.py`
- [LSGA backbone](https://github.com/lzlsxs/hypersc/blob/main/convs/lsga.py): `convs/lsga.py`
- [HSI ResNet](https://github.com/lzlsxs/hypersc/blob/main/convs/resnet_hsi.py): `convs/resnet_hsi.py`
- [Incremental heads](https://github.com/lzlsxs/hypersc/blob/main/convs/linears.py): `convs/linears.py`

### Evaluation

- [Accuracy metrics](https://github.com/lzlsxs/hypersc/blob/main/utils/toolkit.py): `utils/toolkit.py`
- **Task predictions**

### Other components

- **Experiment runner**
- **HSI dataset files**

## Connections

- Experiment runner → CLI entry: starts run
- Experiment runner → Dataset configs: selects dataset
- Dataset configs → CLI entry: configures
- CLI entry → Task orchestration: calls train
- Task orchestration → Task data manager: builds tasks
- Task data manager → HSI preprocessing: prepares samples
- HSI preprocessing → HSI dataset files: reads dataset
- Task orchestration → Model factory: requests model
- Model factory → Hyper-inversion learner: creates learner
- Task orchestration → Hyper-inversion learner: runs task lifecycle
- Hyper-inversion learner → Task data manager: requests task sets
- Hyper-inversion learner → Learner lifecycle: inherits lifecycle
- Hyper-inversion learner → Incremental network: uses classifier
- Hyper-inversion learner → Spectral statistics: stores statistics
- Incremental network → LSGA backbone: selects backbone
- Incremental network → HSI ResNet: selects backbone
- Incremental network → Incremental heads: uses heads
- Hyper-inversion learner → Accuracy metrics: evaluates scores
- Hyper-inversion learner → Task predictions: produces predictions
- Accuracy metrics → Task predictions: scores predictions
