Skip to main content

Waifu2x Python

Python Version License: MIT PyPI version

Python wrapper for waifu2x-ncnn-vulkan with a simple and powerful interface for image and video frame upscaling.

Features

  • High-performance image upscaling using waifu2x-ncnn-vulkan
  • Support for multiple image formats (PNG, JPG, WEBP, etc.)
  • Multiple models including anime and photo styles
  • GPU acceleration with fallback to CPU
  • Batch processing of multiple images
  • Progress tracking and error handling

Installation

pip install waifu2x-python

Dependencies

  • waifu2x-ncnn-vulkan
  • Python 3.8+
  • OpenCV
  • NumPy
  • Pillow

Usage

Basic Example

from waifu2x_python import Waifu2x, ProcessingConfig

# Initialize with default settings
waifu2x = Waifu2x()

# Process a single image
result = waifu2x.process("input.jpg", "output_2x.jpg")
print(f"Processed image saved to: {result.output_path}")

Advanced Configuration

from waifu2x_python import Waifu2x, ProcessingConfig, ModelType

# Custom configuration
config = ProcessingConfig(
    model=ModelType.UPCONV_7_ANIME,  # or ModelType.CUNET, ModelType.UP_PHOTO, etc.
    scale=2,                         # 1, 2, 4, 8, 16, 32
    noise=1,                         # -1 to 3 (-1 = no effect, 0 = no noise reduction, 1-3 = noise reduction level)
    gpu_id=0,                        # -1 for CPU-only, 0 for first GPU, 1 for second GPU, etc.
    tile_size=0,                     # 0 for auto
    num_threads=4                   # Number of CPU threads to use
)

waifu2x = Waifu2x(config=config)

# Process all images in a folder
results = waifu2x.process_folder("input_folder", "output_folder")
print(f"Processed {len([r for r in results if r.success])}/{len(results)} images successfully")

Command Line Interface

# Basic usage
waifu2x -i input.jpg -o output.png

# Process folder recursively
waifu2x -i input_folder -o output_folder -r

# Custom settings
waifu2x -i input.jpg -o output.png -m models-upconv_7_anime_style_art_rgb -s 2 -n 1 -g 0 -t 200

# CPU-only mode
waifu2x -i input.jpg -o output.png -g -1

Available Models

  • models-cunet - High quality denoising and upscaling (default)
  • models-upconv_7_anime_style_art_rgb - For anime-style art
  • models-upconv_7_photo - For photos

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • waifu2x-ncnn-vulkan - The underlying engine
  • ncnn - High-performance neural network inference framework
  • Vulkan - Cross-platform 3D graphics and compute API

Metadata

Release files for waifu2x-python 2.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 waifu2x-python 2.0.4
File Size Uploaded Provenance
waifu2x_python-2.0.4.tar.gz 22.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for waifu2x-python 2.0.4
File Interpreter ABI Platform
waifu2x_python-2.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 43.6 kB

Release files / waifu2x_python-2.0.4.tar.gz

Download URL waifu2x_python-2.0.4.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0309f1e342c834fdec71ff47272af657ccefd5d30ff3ce444ded6772f706f25f
BLAKE2b-256 checksum
How to use checksums
6116cc1fce0e724449418a27b2c95a438024e1a6d7c2effaea469bc6f17bdf4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / waifu2x_python-2.0.4-py3-none-any.whl

Download URL waifu2x_python-2.0.4-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90ae6db8dd190ce0dfe3fe9147f9eb24d6862d5a13969d6e98c53ba3ed55b4d0
BLAKE2b-256 checksum
How to use checksums
da9451b06fc7223ab682ecc1579fde00f01f776fa03ccfc1fcb33f59f4a82fdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Security for waifu2x-python 2.0.4

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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