# djdefrag/qualityscaler architecture

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

- Interactive diagram: https://gitdiagram.com/djdefrag/qualityscaler
- Repository: https://github.com/djdefrag/qualityscaler

## Overview

1. **Repo shape**
   This is a very small, packaging-oriented repository for a Windows desktop application. The core application appears to be a single Python entrypoint, `QualityScaler.py`, with model files expected in `AI-onnx/` and native helper binaries in `Assets/`.

2. **Primary architectural style**
   The app is a **single-process, local-only desktop tool** rather than a client/server system. The README says the entire app is written in Python, including both GUI and processing logic, so the main architecture is a monolithic UI-plus-engine application.

3. **User interface boundary**
   `QualityScaler.py` is the application shell and likely contains the CustomTkinter-based GUI, user settings, file selection, task progress, and orchestration of image/video jobs. The UI is not a separate frontend; it is tightly coupled to the processing pipeline inside the same Python runtime.

4. **Inference engine boundary**
   The AI upscaling work is performed through **ONNX Runtime DirectML** on Windows, which is the key hardware-acceleration layer. This means inference runs locally on DirectX 12-compatible GPUs, with support for multiple GPUs and GPU selection exposed by the app.

5. **Model assets**
   `AI-onnx/` is a runtime asset directory, not source code. The README indicates users must download and place the AI model files there. These models are the core data dependency that determines which upscaler architectures are available, such as BSRGAN, Real-ESRGAN-related models, IRCNN, and SRVGGNetCompact support mentioned in the changelog.

6. **Image-processing flow**
   The image pipeline is: input file selection → optional resize/interpolation settings → tiling for VRAM limits → ONNX inference → reconstruction/output. Automatic tiling is a significant architectural feature because it lets the app handle large images on limited GPU memory without changing the core model.

7. **Video-processing flow**
   Video upscaling is a separate pipeline built around frame extraction and reassembly. The app uses **FFmpeg** for faster frame extraction and likely for final video encoding/muxing, with support for stop/resume on long-running jobs. Video processing also preserves or reattaches audio, per the feature list.

8. **Native helper tools**
   `Assets/exiftool.exe` is a bundled external utility used for metadata extraction and propagation from source to output files. FFmpeg is not committed here, but the README requires the user to place `ffmpeg.exe` in `Assets/`, so the app depends on an external command-line video tool rather than implementing media codecs itself.

9. **Technology stack**
   The repository’s runtime dependencies indicate a Python desktop stack with `customtkinter` for UI, `opencv` for image/video manipulation, `onnx` and `onnxruntime-directml` for inference, and `pyinstaller` for packaging. The mention of PyTorch and onnxconverter-common suggests some model conversion or compatibility support, but the deployed runtime is ONNX-based.

10. **Data and control boundaries**
   All processing is local, with no network dependency in normal operation. The app boundary is therefore: user input files and settings on one side, and processed upscaled images/videos plus optional metadata/audio preservation on the other. This is important for an architecture diagram because the app has no backend service, database, or cloud component.

11. **Operational requirements**
   The application is explicitly Windows-only and expects a DirectX 12-capable GPU with enough VRAM. Those platform constraints are not incidental; they are central to the execution model because DirectML acceleration and bundled Windows executables are part of the architecture.

12. **Packaging/deployment model**
   The presence of `pyinstaller` and the bundled `exiftool.exe`, plus the manual model/FFmpeg placement instructions, suggests a desktop-distribution workflow where the Python app is packaged with external runtime assets. In diagram terms, source code, AI models, and helper binaries are separate deployable inputs consumed by one executable app.

Main entry points: [`QualityScaler.py`](https://github.com/djdefrag/qualityscaler/blob/main/QualityScaler.py) (QualityScaler), [`AI-onnx`](https://github.com/djdefrag/qualityscaler/tree/main/AI-onnx) (AI models), [`requirements.txt`](https://github.com/djdefrag/qualityscaler/blob/main/requirements.txt) (Python deps), [`Assets`](https://github.com/djdefrag/qualityscaler/tree/main/Assets) (FFmpeg flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop app"]
  node_qualityscaler["QualityScaler<br/>Python app<br/>[QualityScaler.py]"]
  node_ui["Desktop UI<br/>CustomTkinter GUI"]
  node_job_orchestrator["Job control<br/>workflow"]
  node_image_pipeline["Image pipeline<br/>upscale flow"]
  node_video_pipeline["Video pipeline<br/>frame flow"]
  node_tiling["Tiling<br/>VRAM strategy"]
  node_inference["ONNX inference<br/>runtime engine"]
  node_gpu_layer["DirectML GPU<br/>accelerator"]
end

subgraph group_assets["Runtime assets"]
  node_frame_tools["FFmpeg flow<br/>video toolchain"]
  node_metadata["ExifTool<br/>metadata tool<br/>[exiftool.exe]"]
  node_models[("AI models<br/>onnx assets")]
  node_model_catalog["Model set<br/>upscaler models"]
end

subgraph group_build["Packaging"]
  node_deps["Python deps<br/>requirements<br/>[requirements.txt]"]
  node_package["PyInstaller<br/>packaging"]
end

node_qualityscaler -->|"hosts"| node_ui
node_qualityscaler -->|"drives"| node_job_orchestrator
node_ui -->|"triggers"| node_job_orchestrator
node_job_orchestrator -->|"routes"| node_image_pipeline
node_job_orchestrator -->|"routes"| node_video_pipeline
node_image_pipeline -->|"uses"| node_tiling
node_image_pipeline -->|"runs"| node_inference
node_video_pipeline -->|"extracts"| node_frame_tools
node_video_pipeline -->|"runs"| node_inference
node_video_pipeline -->|"preserves"| node_metadata
node_inference -->|"accelerates"| node_gpu_layer
node_inference -->|"loads"| node_models
node_models -->|"contains"| node_model_catalog
node_qualityscaler -->|"depends on"| node_deps
node_package -->|"packages"| node_qualityscaler
node_package -->|"includes"| node_deps

click node_qualityscaler "https://github.com/djdefrag/qualityscaler/blob/main/QualityScaler.py"
click node_frame_tools "https://github.com/djdefrag/qualityscaler/tree/main/Assets"
click node_metadata "https://github.com/djdefrag/qualityscaler/blob/main/Assets/exiftool.exe"
click node_models "https://github.com/djdefrag/qualityscaler/tree/main/AI-onnx"
click node_deps "https://github.com/djdefrag/qualityscaler/blob/main/requirements.txt"

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_qualityscaler,node_ui,node_job_orchestrator,node_image_pipeline,node_video_pipeline,node_tiling,node_inference,node_gpu_layer toneBlue
class node_frame_tools,node_metadata,node_models,node_model_catalog toneAmber
class node_deps,node_package toneMint
```

## Components

### Desktop app

Single-process Python application combining UI and processing logic.

- [QualityScaler](https://github.com/djdefrag/qualityscaler/blob/main/QualityScaler.py): Python app · Main application entrypoint and orchestration shell for the desktop tool. · `QualityScaler.py`
- **Desktop UI**: CustomTkinter GUI · User-facing window for settings, file selection, progress, and job control.
- **Job control**: workflow · Coordinates image and video processing, resume/stop behavior, and output handling.
- **Image pipeline**: upscale flow · Processes still images through optional resize, tiling, inference, and reconstruction.
- **Video pipeline**: frame flow · Extracts frames, upscales them, and reassembles video with audio handling.
- **Tiling**: VRAM strategy · Splits large images into tiles to fit GPU memory limits during inference.
- **ONNX inference**: runtime engine · Runs the upscaling model locally using ONNX Runtime DirectML.
- **DirectML GPU**: accelerator · Windows GPU acceleration layer targeted at DirectX 12-capable hardware.

### Runtime assets

External models and bundled helper binaries consumed at runtime.

- [FFmpeg flow](https://github.com/djdefrag/qualityscaler/tree/main/Assets): video toolchain · External command-line path for frame extraction, encoding, and muxing. · `Assets`
- [ExifTool](https://github.com/djdefrag/qualityscaler/blob/main/Assets/exiftool.exe): metadata tool · Bundled utility for reading and propagating file metadata. · `Assets/exiftool.exe`
- [AI models](https://github.com/djdefrag/qualityscaler/tree/main/AI-onnx): onnx assets · Downloaded model files placed at runtime for the available upscalers. · `AI-onnx`
- **Model set**: upscaler models · Supported architectures such as BSRGAN, Real-ESRGAN-related, IRCNN, and SRVGGNetCompact.

### Packaging

Distribution and dependency setup for the Windows desktop build.

- [Python deps](https://github.com/djdefrag/qualityscaler/blob/main/requirements.txt): requirements · Runtime stack including CustomTkinter, OpenCV, ONNX Runtime DirectML, and packaging tools. · `requirements.txt`
- **PyInstaller**: packaging · Build-time packaging path for distributing the Windows desktop application.

## Connections

- QualityScaler → Desktop UI: hosts · The entrypoint creates and runs the desktop interface.
- QualityScaler → Job control: drives · Main app coordinates the processing workflow from user actions.
- Desktop UI → Job control: triggers · User selections and commands start or control jobs.
- Job control → Image pipeline: routes · Dispatches still-image work into the image pipeline.
- Job control → Video pipeline: routes · Dispatches video work into the video pipeline.
- Image pipeline → Tiling: uses · Large images are split into tiles before inference.
- Image pipeline → ONNX inference: runs · Image data is passed through the ONNX model runtime.
- Video pipeline → FFmpeg flow: extracts · Video frames are extracted and reassembled via FFmpeg.
- Video pipeline → ONNX inference: runs · Extracted frames are upscaled through the inference engine.
- Video pipeline → ExifTool: preserves · Metadata is extracted and reapplied across outputs.
- ONNX inference → DirectML GPU: accelerates · Inference executes through DirectML on compatible GPUs.
- ONNX inference → AI models: loads · The runtime loads model files from the AI-onnx directory.
- AI models → Model set: contains · Runtime asset directory stores the supported model families.
- QualityScaler → Python deps: depends on · The application relies on the Python runtime stack listed in requirements.
- PyInstaller → QualityScaler: packages · PyInstaller bundles the Python application for distribution.
- PyInstaller → Python deps: includes · Packaging consumes the Python dependencies for the final build.
