# nagadomi/waifu2x architecture

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

- Interactive diagram: https://gitdiagram.com/nagadomi/waifu2x
- Repository: https://github.com/nagadomi/waifu2x

## Overview

waifu2x is a Torch7 image-restoration application for anime-style art and photos. Its main user workflow runs the command-line tool on an image or image list, selecting noise reduction, 2× upscaling, or both, and writes restored images; a web application is another documented entry point. The repository also supports preparing training data and training custom models. The README establishes these workflows, but the sampled source does not show their internal calls, so edges are limited to documented relationships.

Main entry points: [`waifu2x.lua`](https://github.com/nagadomi/waifu2x/blob/master/waifu2x.lua) (CLI restoration), [`convert_data.lua`](https://github.com/nagadomi/waifu2x/blob/master/convert_data.lua) (Data conversion), [`models`](https://github.com/nagadomi/waifu2x/tree/master/models) (Pretrained models), [`train.lua`](https://github.com/nagadomi/waifu2x/blob/master/train.lua) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_use["Image use"]
  node_cli["CLI restoration<br/>[waifu2x.lua]"]
  node_models[("Pretrained models")]
  node_images["Restored images"]
end

subgraph group_learn["Model training"]
  node_data["Data conversion<br/>[convert_data.lua]"]
  node_trainer["Model training<br/>[train.lua]"]
end

subgraph group_web["Web application"]
  node_webapp["Web server<br/>[web.lua]"]
end

node_user(("Image user"))
node_datauser(("Model developer"))
node_webuser(("Web user"))

node_user -->|"submits image"| node_cli
node_cli -->|"selects model"| node_models
node_cli -->|"writes results"| node_images
node_datauser -->|"prepares data"| node_data
node_data -->|"provides training data"| node_trainer
node_webuser -->|"opens application"| node_webapp

click node_cli "https://github.com/nagadomi/waifu2x/blob/master/waifu2x.lua"
click node_models "https://github.com/nagadomi/waifu2x/tree/master/models"
click node_data "https://github.com/nagadomi/waifu2x/blob/master/convert_data.lua"
click node_trainer "https://github.com/nagadomi/waifu2x/blob/master/train.lua"
click node_webapp "https://github.com/nagadomi/waifu2x/blob/master/web.lua"

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_cli,node_models,node_images,node_user,node_webuser toneBlue
class node_data,node_trainer toneAmber
class node_webapp toneMint
class node_datauser toneIndigo
```

## Components

### Image use

- [CLI restoration](https://github.com/nagadomi/waifu2x/blob/master/waifu2x.lua): `waifu2x.lua`
- [Pretrained models](https://github.com/nagadomi/waifu2x/tree/master/models): `models`
- **Restored images**

### Model training

- [Data conversion](https://github.com/nagadomi/waifu2x/blob/master/convert_data.lua): `convert_data.lua`
- [Model training](https://github.com/nagadomi/waifu2x/blob/master/train.lua): `train.lua`

### Web application

- [Web server](https://github.com/nagadomi/waifu2x/blob/master/web.lua): `web.lua`

### Other components

- **Image user**
- **Model developer**
- **Web user**

## Connections

- Image user → CLI restoration: submits image (evidence: `README.md`)
- CLI restoration → Pretrained models: selects model (evidence: `README.md`)
- CLI restoration → Restored images: writes results (evidence: `README.md`)
- Model developer → Data conversion: prepares data (evidence: `README.md`)
- Data conversion → Model training: provides training data (evidence: `README.md`)
- Web user → Web server: opens application (evidence: `README.md`)
