How djdefrag/qualityscaler works
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 QualityScaler · AI-onnx AI models · requirements.txt Python deps · Assets FFmpeg flow
Components 14
Desktop app
Single-process Python application combining UI and processing logic.
- QualityScaler · Main application entrypoint and orchestration shell for the desktop tool.
QualityScaler.py - Desktop UI · User-facing window for settings, file selection, progress, and job control.
- Job control · Coordinates image and video processing, resume/stop behavior, and output handling.
- Image pipeline · Processes still images through optional resize, tiling, inference, and reconstruction.
- Video pipeline · Extracts frames, upscales them, and reassembles video with audio handling.
- Tiling · Splits large images into tiles to fit GPU memory limits during inference.
- ONNX inference · Runs the upscaling model locally using ONNX Runtime DirectML.
- DirectML GPU · Windows GPU acceleration layer targeted at DirectX 12-capable hardware.
Runtime assets
External models and bundled helper binaries consumed at runtime.
- FFmpeg flow · External command-line path for frame extraction, encoding, and muxing.
Assets - ExifTool · Bundled utility for reading and propagating file metadata.
Assets/exiftool.exe - AI models · Downloaded model files placed at runtime for the available upscalers.
AI-onnx - Model set · Supported architectures such as BSRGAN, Real-ESRGAN-related, IRCNN, and SRVGGNetCompact.
Packaging
Distribution and dependency setup for the Windows desktop build.
- Python deps · Runtime stack including CustomTkinter, OpenCV, ONNX Runtime DirectML, and packaging tools.
requirements.txt - PyInstaller · Build-time packaging path for distributing the Windows desktop application.
Connections 16
- 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.