Skip to main content

A cross-platform AI upscaling utility to upscale images to a higher resolution.

Project description

py_img_scaler

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

Powered natively by torchsr (NinaSR). Supports hardware acceleration across NVIDIA, AMD, and Apple Silicon.


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.14 (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 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. Working with the API Directly

import logging
from py_img_scaler import AIUpscaler, ContextConfiguration, setup_logging

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

# 2. Build your configuration layer context matrix
config = ContextConfiguration(
    model="1",            # NinaSR-B1 architecture pipeline footprint
    tile_size=400,        # Slicing chunk constraints to prevent VRAM crashes
    target_width=5120,    # Target 5K Wide aspect dimension matching
    target_height=2160    # Target 2160p height matching
)

try:
    # 3. Instantiate the execution engine (Auto-detects CUDA / MPS / CPU)
    # Will work on all platforms MacOS / Windows / Linux
    engine = AIUpscaler(config=config)
    
    # 4. Ingest and upscale individual physical media frames
    success = engine.upscale_img(
        input_path="./input_photos/raw_horizon.jpg",
        output_path="./output_upscaled_photos/5k_horizon.jpg"
    )
    
    if success:
        logger.info("Image upscale task executed successfully.")

except ValueError as e:
    logger.error(f"Configuration boundary violation detected: {e}")
except Exception as e:
    logger.exception(f"Engine processing crash: {e}")

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_img_scaler-0.0.3.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_img_scaler-0.0.3-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file py_img_scaler-0.0.3.tar.gz.

File metadata

  • Download URL: py_img_scaler-0.0.3.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_img_scaler-0.0.3.tar.gz
Algorithm Hash digest
SHA256 af704fe550a1d751bbe6e541c6561a0114b5cdce986fa3570a08bedd0a360d86
MD5 7c55e3d8c8437d888fdaa495a5f83522
BLAKE2b-256 fb2355d7d2c606cbdf2cdf18e26fe5b565a12ff4ead9fab8a395964d371aa3e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_img_scaler-0.0.3.tar.gz:

Publisher: python-publish.yml on ManuelSaleta/py-img-scaler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_img_scaler-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_img_scaler-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_img_scaler-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5e3fdd5a8c99170d129c982a06982ff4206ac9fc0c8f9f48ce68857f9f3794c1
MD5 33f22f20c752b67bdaf99746faca0068
BLAKE2b-256 5a1dfa21d74f9e959a4c70f4cc576884a221682f300d2abf26a05d3356015054

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_img_scaler-0.0.3-py3-none-any.whl:

Publisher: python-publish.yml on ManuelSaleta/py-img-scaler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page