Skip to main content

py_img_scaler

Tests

A cross-platform, high-performance image upscaling tool, leverages AI image processing.

Powered natively by torchsr (NinaSR).


Features

  • Cross-Platform Acceleration: Native support for NVIDIA CUDA, AMD ROCm (Linux via HIP), and Apple Silicon (macOS via MPS).
  • VRAM Safety: Smart local tiling/patching with edge-padding blending to prevent Out-of-Memory (OOM) errors on large files.

Prerequisites & Installation

1. System Dependencies (Linux)

Ensure Python 3.13 (recommended) and your platform graphics drivers (ROCm/CUDA) are installed.

2. Automated Environment Setup

The project contains a platform-aware pipeline configuration tracker. Run the following command to completely clean, generate the virtual environment, and map the correct vendor binaries for your host OS:

make fresh

Additional Make recipes

    make venv         - Create a clean local virtual environment using $(PYTHON_BIN)
    make install      - Upgrade core tooling and install platform-specific packages
    make install-dev  - Install dev dependencies like ruff, pytest etc.
    make run          - Execute py_img_scaler main loop
    make clean        - Destroy virtual environment and cached bytecodes
    make lint         - Runs, Black, Ruff, and MyPy checks
    make check        - Only check Black, Ruff, and MyPy checks
    make test         - Run all unit tests inside the tests directory

Usage Examples

1. Command-Line Interface (CLI)

CLI Arguments Matrix

Short Flag Long Flag Description Default / Allowed Values
-s --source Path to the directory containing input images. Required
-d --destination Path to the directory for upscaled assets. Required
-m --model Select target torchsr architecture scale depth. 0, 1, or 2
-W --width Force target width bounding configuration. 1920
-H --height Force target height bounding configuration. 1080

Once your environment is provisioned, invoke the processing pipeline directly using explicit configuration flags:

    # Basic execution utilizing default resolutions
    py_img_scaler --source ./input_photos --destination ./upscaled_output --model 1

    # Advanced execution overriding targets for a crisp 5K Ultra-Wide frame canvas
    py_img_scaler -s ./wallpapers -d ./output -m 2 -W 5120 -H 2160

2. Simple Configuation

from py_img_scaler import ImgScaler, ContextConfiguration

# 1. Use the factory to load defaults (or .env file variables)
# This auto-sets resolution, model, and tile sizes to safe defaults.
config = ContextConfiguration.from_runtime()

# 2. Instantiate and run
engine = ImgScaler(config=config)
engine.upscale_img(
    input_path="./my_photo.jpg",
    output_path="./upscaled_photo.jpg"
)

3. Advanced Configuration

import logging
from pathlib import Path
from src.py_img_scaler import ImgScaler, ContextConfiguration, setup_logging

# 1. Attach your application context to the logging stream
setup_logging()
logger = logging.getLogger("py_img_scaler.core")


# 2. Build a custom configuration matrix
config = ContextConfiguration(
    model="1",                          # Options: "0", "1", "2" - 3 is most demanding model
    tile_size=400,                      # Adjust lower if you encounter VRAM Out-Of-Memory errors
    target_width=5120,                  # Adjust your upscaling target width
    target_height=2160,                 # Adjust your upscaling target height
    source_dir=Path("./input"),         # Input dir containing your images.
    destination_dir=Path("./output")    # Destination dir
)

# 3. Instantiate the engine (Auto-detects CUDA / MPS / CPU)
engine = ImgScaler(config=config)

# 4. Upscale images
engine.upscale_img("./input/raw_horizon.jpg", "./output/5k_horizon.jpg")

License

  • This project is open-source software licensed under the GNU General Public License v3.0 (GPLv3).

Key Terms & Copyleft Requirements:

  • See the accompanying LICENSE file at the root of this repository for the full legal text.

Metadata

Release files for py-img-scaler 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-img-scaler 0.0.4
File Size Uploaded
py_img_scaler-0.0.4.tar.gz 24.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-img-scaler 0.0.4
File Interpreter ABI Platform
py_img_scaler-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 47.9 kB

Release files / py_img_scaler-0.0.4.tar.gz

Download URL py_img_scaler-0.0.4.tar.gz
Size 24.1 kB
Tags Source
SHA-256 checksum
How to use checksums
da23bfb0f1f08096934a3730860d4245ffcdcb159c5698170546962199d8b8bc
BLAKE2b-256 checksum
How to use checksums
5c7f69f67c60a5d5d2601142e70381f3e7674288e03ab330185bc87a3e263967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release files / py_img_scaler-0.0.4-py3-none-any.whl

Download URL py_img_scaler-0.0.4-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
939d3e2fe74c3340ac53f72f5805a0eaa5478ba34d7a581ad7e99ca6979ea701
BLAKE2b-256 checksum
How to use checksums
d08a36daaac860279fe91196a5a5b6017571f02cb8e464dfc8fdf52a0e5933e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page