# va1shn9v/promptir architecture

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

- Interactive diagram: https://gitdiagram.com/va1shn9v/promptir
- Repository: https://github.com/va1shn9v/promptir

## Overview

PromptIR is a research codebase for all-in-one blind image restoration: it trains a prompt-guided network across denoising, deraining, and dehazing, then applies it to degraded images for evaluation or visual output. The principal training workflow builds degradation-labelled image patches, trains the network against clean patches, and saves checkpoints. Inference accepts images, runs the model (optionally by tiles), and saves restored images; testing also supports task-specific evaluation. Some links reflect README-documented behavior because test.py and parts of the dataset and model implementations were not sampled.

Main entry points: [`train.py`](https://github.com/va1shn9v/promptir/blob/main/train.py) (Training runner), [`demo.py`](https://github.com/va1shn9v/promptir/blob/main/demo.py) (Demo runner), [`test.py`](https://github.com/va1shn9v/promptir/blob/main/test.py) (Test runner), [`utils/dataset_utils.py`](https://github.com/va1shn9v/promptir/blob/main/utils/dataset_utils.py) (Training dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_train_data["Training dataset<br/>[dataset_utils.py]"]
  node_degradation["Degradation generation"]
  node_data_files["Dataset manifests"]
end

subgraph group_training["Model training"]
  node_options["Run configuration<br/>[options.py]"]
  node_train["Training runner<br/>[train.py]"]
  node_model["PromptIR network<br/>[model.py]"]
  node_loss["Training loss<br/>[train.py]"]
  node_scheduler["Learning-rate scheduler<br/>[schedulers.py]"]
  node_checkpoint["Saved checkpoints"]
end

subgraph group_inference["Restoration inference"]
  node_demo["Demo runner<br/>[demo.py]"]
  node_image_io["Image loading and saving<br/>[image_io.py]"]
end

subgraph group_evaluation["Testing and metrics"]
  node_test["Test runner<br/>[test.py]"]
  node_test_data["Image test datasets<br/>[dataset_utils.py]"]
  node_metrics["Quality metrics<br/>[val_utils.py]"]
end

node_user(("Researcher"))
node_images["Input images"]
node_restored["Restored images"]
node_logger["Training logger"]

node_user -->|"sets parameters"| node_options
node_user -->|"starts training"| node_train
node_options -->|"configures"| node_train
node_train -->|"builds dataset"| node_train_data
node_train_data -->|"reads manifests"| node_data_files
node_train_data -->|"generates corruptions"| node_degradation
node_train -->|"trains network"| node_model
node_train -->|"computes loss"| node_loss
node_train -->|"steps schedule"| node_scheduler
node_train -->|"saves checkpoints"| node_checkpoint
node_train -.->|"logs metrics"| node_logger
node_user -->|"requests restoration"| node_demo
node_demo -->|"loads test images"| node_test_data
node_demo -->|"reads and writes"| node_image_io
node_demo -->|"loads checkpoint"| node_checkpoint
node_demo -->|"runs inference"| node_model
node_images -->|"provides images"| node_demo
node_demo -->|"writes results"| node_restored
node_user -->|"runs evaluation"| node_test
node_test -->|"selects task data"| node_test_data
node_test -->|"loads checkpoint"| node_checkpoint
node_test -->|"evaluates network"| node_model
node_test -->|"computes scores"| node_metrics

click node_options "https://github.com/va1shn9v/promptir/blob/main/options.py"
click node_train "https://github.com/va1shn9v/promptir/blob/main/train.py"
click node_train_data "https://github.com/va1shn9v/promptir/blob/main/utils/dataset_utils.py"
click node_degradation "https://github.com/va1shn9v/promptir/blob/main/utils/degradation_utils.py"
click node_data_files "https://github.com/va1shn9v/promptir/tree/main/data_dir"
click node_model "https://github.com/va1shn9v/promptir/blob/main/net/model.py"
click node_loss "https://github.com/va1shn9v/promptir/blob/main/train.py"
click node_scheduler "https://github.com/va1shn9v/promptir/blob/main/utils/schedulers.py"
click node_checkpoint "https://github.com/va1shn9v/promptir/tree/main/ckpt"
click node_demo "https://github.com/va1shn9v/promptir/blob/main/demo.py"
click node_test "https://github.com/va1shn9v/promptir/blob/main/test.py"
click node_test_data "https://github.com/va1shn9v/promptir/blob/main/utils/dataset_utils.py"
click node_image_io "https://github.com/va1shn9v/promptir/blob/main/utils/image_io.py"
click node_metrics "https://github.com/va1shn9v/promptir/blob/main/utils/val_utils.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_train_data,node_degradation,node_data_files toneBlue
class node_options,node_train,node_model,node_loss,node_scheduler,node_checkpoint toneAmber
class node_demo,node_image_io toneMint
class node_test,node_test_data,node_metrics toneRose
class node_user,node_images,node_restored,node_logger toneIndigo
```

## Components

### Data preparation

- [Training dataset](https://github.com/va1shn9v/promptir/blob/main/utils/dataset_utils.py): `utils/dataset_utils.py`
- [Degradation generation](https://github.com/va1shn9v/promptir/blob/main/utils/degradation_utils.py): `utils/degradation_utils.py`
- [Dataset manifests](https://github.com/va1shn9v/promptir/tree/main/data_dir): `data_dir`

### Model training

- [Run configuration](https://github.com/va1shn9v/promptir/blob/main/options.py): `options.py`
- [Training runner](https://github.com/va1shn9v/promptir/blob/main/train.py): `train.py`
- [PromptIR network](https://github.com/va1shn9v/promptir/blob/main/net/model.py): `net/model.py`
- [Training loss](https://github.com/va1shn9v/promptir/blob/main/train.py): `train.py`
- [Learning-rate scheduler](https://github.com/va1shn9v/promptir/blob/main/utils/schedulers.py): `utils/schedulers.py`
- [Saved checkpoints](https://github.com/va1shn9v/promptir/tree/main/ckpt): `ckpt`

### Restoration inference

- [Demo runner](https://github.com/va1shn9v/promptir/blob/main/demo.py): `demo.py`
- [Image loading and saving](https://github.com/va1shn9v/promptir/blob/main/utils/image_io.py): `utils/image_io.py`

### Testing and metrics

- [Test runner](https://github.com/va1shn9v/promptir/blob/main/test.py): `test.py`
- [Image test datasets](https://github.com/va1shn9v/promptir/blob/main/utils/dataset_utils.py): `utils/dataset_utils.py`
- [Quality metrics](https://github.com/va1shn9v/promptir/blob/main/utils/val_utils.py): `utils/val_utils.py`

### Other components

- **Researcher**
- **Input images**
- **Restored images**
- **Training logger**

## Connections

- Researcher → Run configuration: sets parameters
- Researcher → Training runner: starts training
- Run configuration → Training runner: configures
- Training runner → Training dataset: builds dataset
- Training dataset → Dataset manifests: reads manifests
- Training dataset → Degradation generation: generates corruptions
- Training runner → PromptIR network: trains network
- Training runner → Training loss: computes loss
- Training runner → Learning-rate scheduler: steps schedule
- Training runner → Saved checkpoints: saves checkpoints
- Training runner → Training logger: logs metrics
- Researcher → Demo runner: requests restoration
- Demo runner → Image test datasets: loads test images
- Demo runner → Image loading and saving: reads and writes
- Demo runner → Saved checkpoints: loads checkpoint
- Demo runner → PromptIR network: runs inference
- Input images → Demo runner: provides images
- Demo runner → Restored images: writes results
- Researcher → Test runner: runs evaluation
- Test runner → Image test datasets: selects task data
- Test runner → Saved checkpoints: loads checkpoint
- Test runner → PromptIR network: evaluates network
- Test runner → Quality metrics: computes scores
