# neosr-project/neosr architecture

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

- Interactive diagram: https://gitdiagram.com/neosr-project/neosr
- Repository: https://github.com/neosr-project/neosr

## Overview

neosr is a configurable framework for training and evaluating single-image super-resolution models. Users launch training with a TOML configuration; the training entry point prepares datasets and loaders, then runs a registered model. The image model coordinates network, loss, augmentation, optimization and validation/metrics behavior. Major documented capabilities include many restoration architectures, discriminators, loss functions, optimizers and degradations. The graph preserves these branches, but sampled excerpts do not expose every runtime dispatch or the complete training loop, so uncertain connections are omitted.

Main entry points: [`neosr/models/image.py`](https://github.com/neosr-project/neosr/blob/master/neosr/models/image.py) (Image restoration model), [`train.py`](https://github.com/neosr-project/neosr/blob/master/train.py) (Training runner), [`neosr/data/otf_dataset.py`](https://github.com/neosr-project/neosr/blob/master/neosr/data/otf_dataset.py) (On-the-fly degradation), [`neosr/data`](https://github.com/neosr-project/neosr/tree/master/neosr/data) (Datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Configuration and training"]
  node_training["Training runner<br/>[train.py]"]
end

subgraph group_data["Image data pipeline"]
  node_datasets["Datasets"]
  node_paired["Paired images<br/>[paired_dataset.py]"]
  node_otf["On-the-fly degradation<br/>[otf_dataset.py]"]
  node_degradations["Degradation operators<br/>[degradations.py]"]
  node_augment["Image augmentation<br/>[augmentations.py]"]
  node_transforms["Image transforms<br/>[transforms.py]"]
  node_storage["File backends<br/>[file_client.py]"]
end

subgraph group_models["Restoration and evaluation"]
  node_architectures["SR architectures"]
  node_archutil["Architecture utilities<br/>[arch_util.py]"]
  node_image_model["Image restoration model<br/>[image.py]"]
  node_base_model["Base model runtime<br/>[base.py]"]
  node_metrics["Image quality metrics"]
end

subgraph group_learning["Learning components"]
  node_losses["Loss functions"]
  node_optim_sf["AdamW schedule-free<br/>[adamw_sf.py]"]
  node_optim_adan["Adan optimizer<br/>[adan.py]"]
  node_optim_adansf["Adan schedule-free<br/>[adan_sf.py]"]
  node_optim_soap["SOAP optimizer<br/>[soap_sf.py]"]
  node_optim_other["Other optimizers"]
end

subgraph group_support["Runtime support"]
  node_config["Options and seeding<br/>[options.py]"]
  node_registry["Component registries<br/>[registry.py]"]
  node_jpeg["Differentiable JPEG<br/>[diffjpeg.py]"]
  node_imageutil["Image utilities<br/>[img_util.py]"]
  node_color["Color conversion<br/>[color_util.py]"]
  node_distributed["Distributed runtime<br/>[dist_util.py]"]
  node_misc["Experiment utilities<br/>[misc.py]"]
  node_rng["Randomness control<br/>[rng.py]"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_training
node_training -->|"loads options"| node_config
node_training -->|"builds datasets"| node_datasets
node_training -->|"runs model"| node_image_model
node_training -->|"uses runtime"| node_distributed
node_config -->|"sets up"| node_distributed
node_datasets -.->|"offers paired data"| node_paired
node_datasets -.->|"offers synthetic degradation"| node_otf
node_otf -->|"applies"| node_degradations
node_otf -->|"uses"| node_transforms
node_otf -->|"reads files"| node_storage
node_otf -->|"uses"| node_augment
node_degradations -->|"samples randomness"| node_rng
node_augment -->|"uses"| node_rng
node_image_model -->|"builds networks"| node_architectures
node_image_model -->|"augments batches"| node_augment
node_image_model -->|"computes losses"| node_losses
node_image_model -->|"evaluates results"| node_metrics
node_image_model -->|"extends runtime"| node_base_model
node_image_model -->|"uses optimizer"| node_optim_sf
node_image_model -->|"uses optimizer"| node_optim_adan
node_image_model -->|"uses optimizer"| node_optim_adansf
node_image_model -->|"uses optimizer"| node_optim_soap
node_image_model -.->|"supports optimizers"| node_optim_other
node_image_model -->|"uses degradation"| node_jpeg
node_architectures -->|"registers components"| node_registry
node_architectures -->|"uses utilities"| node_archutil
node_image_model -->|"resolves components"| node_registry
node_metrics -->|"converts images"| node_imageutil
node_metrics -->|"uses perceptual metric"| node_losses
node_otf -->|"uses compression"| node_jpeg
node_imageutil -.->|"uses conversions"| node_color
node_training -.->|"manages experiments"| node_misc

click node_training "https://github.com/neosr-project/neosr/blob/master/train.py"
click node_config "https://github.com/neosr-project/neosr/blob/master/neosr/utils/options.py"
click node_registry "https://github.com/neosr-project/neosr/blob/master/neosr/utils/registry.py"
click node_datasets "https://github.com/neosr-project/neosr/tree/master/neosr/data"
click node_paired "https://github.com/neosr-project/neosr/blob/master/neosr/data/paired_dataset.py"
click node_otf "https://github.com/neosr-project/neosr/blob/master/neosr/data/otf_dataset.py"
click node_degradations "https://github.com/neosr-project/neosr/blob/master/neosr/data/degradations.py"
click node_augment "https://github.com/neosr-project/neosr/blob/master/neosr/data/augmentations.py"
click node_transforms "https://github.com/neosr-project/neosr/blob/master/neosr/data/transforms.py"
click node_storage "https://github.com/neosr-project/neosr/blob/master/neosr/data/file_client.py"
click node_architectures "https://github.com/neosr-project/neosr/tree/master/neosr/archs"
click node_archutil "https://github.com/neosr-project/neosr/blob/master/neosr/archs/arch_util.py"
click node_image_model "https://github.com/neosr-project/neosr/blob/master/neosr/models/image.py"
click node_base_model "https://github.com/neosr-project/neosr/blob/master/neosr/models/base.py"
click node_losses "https://github.com/neosr-project/neosr/tree/master/neosr/losses"
click node_metrics "https://github.com/neosr-project/neosr/tree/master/neosr/metrics"
click node_optim_sf "https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adamw_sf.py"
click node_optim_adan "https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adan.py"
click node_optim_adansf "https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adan_sf.py"
click node_optim_soap "https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/soap_sf.py"
click node_optim_other "https://github.com/neosr-project/neosr/tree/master/neosr/optimizers"
click node_jpeg "https://github.com/neosr-project/neosr/blob/master/neosr/utils/diffjpeg.py"
click node_imageutil "https://github.com/neosr-project/neosr/blob/master/neosr/utils/img_util.py"
click node_color "https://github.com/neosr-project/neosr/blob/master/neosr/utils/color_util.py"
click node_distributed "https://github.com/neosr-project/neosr/blob/master/neosr/utils/dist_util.py"
click node_misc "https://github.com/neosr-project/neosr/blob/master/neosr/utils/misc.py"
click node_rng "https://github.com/neosr-project/neosr/blob/master/neosr/utils/rng.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_training toneBlue
class node_datasets,node_paired,node_otf,node_degradations,node_augment,node_transforms,node_storage toneAmber
class node_architectures,node_archutil,node_image_model,node_base_model,node_metrics toneMint
class node_losses,node_optim_sf,node_optim_adan,node_optim_adansf,node_optim_soap,node_optim_other toneRose
class node_config,node_registry,node_jpeg,node_imageutil,node_color,node_distributed,node_misc,node_rng,node_user toneIndigo
```

## Components

### Configuration and training

- [Training runner](https://github.com/neosr-project/neosr/blob/master/train.py): `train.py`

### Image data pipeline

- [Datasets](https://github.com/neosr-project/neosr/tree/master/neosr/data): `neosr/data`
- [Paired images](https://github.com/neosr-project/neosr/blob/master/neosr/data/paired_dataset.py): `neosr/data/paired_dataset.py`
- [On-the-fly degradation](https://github.com/neosr-project/neosr/blob/master/neosr/data/otf_dataset.py): `neosr/data/otf_dataset.py`
- [Degradation operators](https://github.com/neosr-project/neosr/blob/master/neosr/data/degradations.py): `neosr/data/degradations.py`
- [Image augmentation](https://github.com/neosr-project/neosr/blob/master/neosr/data/augmentations.py): `neosr/data/augmentations.py`
- [Image transforms](https://github.com/neosr-project/neosr/blob/master/neosr/data/transforms.py): `neosr/data/transforms.py`
- [File backends](https://github.com/neosr-project/neosr/blob/master/neosr/data/file_client.py): `neosr/data/file_client.py`

### Restoration and evaluation

- [SR architectures](https://github.com/neosr-project/neosr/tree/master/neosr/archs): `neosr/archs`
- [Architecture utilities](https://github.com/neosr-project/neosr/blob/master/neosr/archs/arch_util.py): `neosr/archs/arch_util.py`
- [Image restoration model](https://github.com/neosr-project/neosr/blob/master/neosr/models/image.py): `neosr/models/image.py`
- [Base model runtime](https://github.com/neosr-project/neosr/blob/master/neosr/models/base.py): `neosr/models/base.py`
- [Image quality metrics](https://github.com/neosr-project/neosr/tree/master/neosr/metrics): `neosr/metrics`

### Learning components

- [Loss functions](https://github.com/neosr-project/neosr/tree/master/neosr/losses): `neosr/losses`
- [AdamW schedule-free](https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adamw_sf.py): `neosr/optimizers/adamw_sf.py`
- [Adan optimizer](https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adan.py): `neosr/optimizers/adan.py`
- [Adan schedule-free](https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/adan_sf.py): `neosr/optimizers/adan_sf.py`
- [SOAP optimizer](https://github.com/neosr-project/neosr/blob/master/neosr/optimizers/soap_sf.py): `neosr/optimizers/soap_sf.py`
- [Other optimizers](https://github.com/neosr-project/neosr/tree/master/neosr/optimizers): `neosr/optimizers`

### Runtime support

- [Options and seeding](https://github.com/neosr-project/neosr/blob/master/neosr/utils/options.py): `neosr/utils/options.py`
- [Component registries](https://github.com/neosr-project/neosr/blob/master/neosr/utils/registry.py): `neosr/utils/registry.py`
- [Differentiable JPEG](https://github.com/neosr-project/neosr/blob/master/neosr/utils/diffjpeg.py): `neosr/utils/diffjpeg.py`
- [Image utilities](https://github.com/neosr-project/neosr/blob/master/neosr/utils/img_util.py): `neosr/utils/img_util.py`
- [Color conversion](https://github.com/neosr-project/neosr/blob/master/neosr/utils/color_util.py): `neosr/utils/color_util.py`
- [Distributed runtime](https://github.com/neosr-project/neosr/blob/master/neosr/utils/dist_util.py): `neosr/utils/dist_util.py`
- [Experiment utilities](https://github.com/neosr-project/neosr/blob/master/neosr/utils/misc.py): `neosr/utils/misc.py`
- [Randomness control](https://github.com/neosr-project/neosr/blob/master/neosr/utils/rng.py): `neosr/utils/rng.py`

### Other components

- **Researcher**

## Connections

- Researcher → Training runner: starts training
- Training runner → Options and seeding: loads options (evidence: `train.py`)
- Training runner → Datasets: builds datasets (evidence: `train.py`)
- Training runner → Image restoration model: runs model (evidence: `train.py`)
- Training runner → Distributed runtime: uses runtime (evidence: `train.py`)
- Options and seeding → Distributed runtime: sets up (evidence: `neosr/utils/options.py`)
- Datasets → Paired images: offers paired data
- Datasets → On-the-fly degradation: offers synthetic degradation (evidence: `neosr/data/otf_dataset.py`)
- On-the-fly degradation → Degradation operators: applies (evidence: `neosr/data/otf_dataset.py`)
- On-the-fly degradation → Image transforms: uses (evidence: `neosr/data/otf_dataset.py`)
- On-the-fly degradation → File backends: reads files (evidence: `neosr/data/otf_dataset.py`)
- On-the-fly degradation → Image augmentation: uses (evidence: `neosr/data/otf_dataset.py`)
- Degradation operators → Randomness control: samples randomness (evidence: `neosr/data/degradations.py`)
- Image augmentation → Randomness control: uses (evidence: `neosr/data/augmentations.py`)
- Image restoration model → SR architectures: builds networks (evidence: `neosr/models/image.py`)
- Image restoration model → Image augmentation: augments batches (evidence: `neosr/models/image.py`)
- Image restoration model → Loss functions: computes losses (evidence: `neosr/models/image.py`)
- Image restoration model → Image quality metrics: evaluates results (evidence: `neosr/models/image.py`)
- Image restoration model → Base model runtime: extends runtime (evidence: `neosr/models/image.py`)
- Image restoration model → AdamW schedule-free: uses optimizer (evidence: `neosr/models/image.py`)
- Image restoration model → Adan optimizer: uses optimizer (evidence: `neosr/models/image.py`)
- Image restoration model → Adan schedule-free: uses optimizer (evidence: `neosr/models/image.py`)
- Image restoration model → SOAP optimizer: uses optimizer (evidence: `neosr/models/image.py`)
- Image restoration model → Other optimizers: supports optimizers (evidence: `neosr/models/image.py`)
- Image restoration model → Differentiable JPEG: uses degradation (evidence: `neosr/models/otf.py`)
- SR architectures → Component registries: registers components (evidence: `neosr/archs/__init__.py`)
- SR architectures → Architecture utilities: uses utilities (evidence: `neosr/archs/atd_arch.py`)
- Image restoration model → Component registries: resolves components (evidence: `neosr/models/image.py`)
- Image quality metrics → Image utilities: converts images (evidence: `neosr/metrics/calculate.py`)
- Image quality metrics → Loss functions: uses perceptual metric (evidence: `neosr/metrics/calculate.py`)
- On-the-fly degradation → Differentiable JPEG: uses compression
- Image utilities → Color conversion: uses conversions
- Training runner → Experiment utilities: manages experiments
