Skip to main content

High-performance Python wrapper for waifu2x-ncnn-vulkan with GPU/CPU support

Project description

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 (automatically downloaded)
  • Python 3.8+
  • OpenCV
  • NumPy
  • Pillow
  • tqdm

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
    verbose=True                     # Enable verbose output
)

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
  • models-upconv_7_anime_style_art_rgb_noise0 - For clean anime-style art
  • models-upconv_7_anime_style_art_rgb_noise1 - For slightly noisy anime-style art
  • models-upconv_7_anime_style_art_rgb_noise2 - For noisy anime-style art
  • models-upconv_7_anime_style_art_rgb_noise3 - For very noisy anime-style art

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

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

waifu2x_python-2.0.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

waifu2x_python-2.0.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file waifu2x_python-2.0.0.tar.gz.

File metadata

  • Download URL: waifu2x_python-2.0.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for waifu2x_python-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6984a8145df4b6052c5fe440d479dbd27dcff109de3b0bd7b9001af7564a4eaa
MD5 af5a5bb38dad4881662b832ea618d505
BLAKE2b-256 f155496f6bbd6482d6138ee20d8db4d83e1e3ef048b3d0e895d0f5075a23bb82

See more details on using hashes here.

File details

Details for the file waifu2x_python-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: waifu2x_python-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for waifu2x_python-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f5b657ae4aa8e336714ac1d8a1e9fc6e46ae125d1324f0c63a5159bafb137af
MD5 2e2ae1c5ab4c6bfad978e02ac7f476cc
BLAKE2b-256 b3faaba67f88b0e8b626f75f88f75d896539fb97e9a11d0cf471f7ed424aed83

See more details on using hashes here.

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