A cross-platform AI upscaling utility to upscale images to a higher resolution.
Project description
py_img_scaler
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
LICENSEfile at the root of this repository for the full legal text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_img_scaler-0.0.4.tar.gz.
File metadata
- Download URL: py_img_scaler-0.0.4.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da23bfb0f1f08096934a3730860d4245ffcdcb159c5698170546962199d8b8bc
|
|
| MD5 |
9d817ca7dfc71933c33eb09e3ffd7a87
|
|
| BLAKE2b-256 |
5c7f69f67c60a5d5d2601142e70381f3e7674288e03ab330185bc87a3e263967
|
Provenance
The following attestation bundles were made for py_img_scaler-0.0.4.tar.gz:
Publisher:
python-publish.yml on ManuelSaleta/py-img-scaler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_img_scaler-0.0.4.tar.gz -
Subject digest:
da23bfb0f1f08096934a3730860d4245ffcdcb159c5698170546962199d8b8bc - Sigstore transparency entry: 2203567101
- Sigstore integration time:
-
Permalink:
ManuelSaleta/py-img-scaler@a1dc677f8efee5ac3be71f42f33627615ce2d731 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/ManuelSaleta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a1dc677f8efee5ac3be71f42f33627615ce2d731 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_img_scaler-0.0.4-py3-none-any.whl.
File metadata
- Download URL: py_img_scaler-0.0.4-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.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
939d3e2fe74c3340ac53f72f5805a0eaa5478ba34d7a581ad7e99ca6979ea701
|
|
| MD5 |
64e6e36d31e5a1d8346d117911763711
|
|
| BLAKE2b-256 |
d08a36daaac860279fe91196a5a5b6017571f02cb8e464dfc8fdf52a0e5933e4
|
Provenance
The following attestation bundles were made for py_img_scaler-0.0.4-py3-none-any.whl:
Publisher:
python-publish.yml on ManuelSaleta/py-img-scaler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_img_scaler-0.0.4-py3-none-any.whl -
Subject digest:
939d3e2fe74c3340ac53f72f5805a0eaa5478ba34d7a581ad7e99ca6979ea701 - Sigstore transparency entry: 2203567113
- Sigstore integration time:
-
Permalink:
ManuelSaleta/py-img-scaler@a1dc677f8efee5ac3be71f42f33627615ce2d731 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/ManuelSaleta
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@a1dc677f8efee5ac3be71f42f33627615ce2d731 -
Trigger Event:
release
-
Statement type: